5 years ago
Laravel and Laravel cant connect to socket

Posted 5 years ago by sj

Hi all,

i have searched the whole WWW and i just cant find any good tutorial on how to setup and laravel.

Right now i have my server.js file

var express = require('express'),
    app = express(),
    server = require('http').createServer(app),
    io = require('').listen(server),
    logger = require('winston'),
    port = 3000;


// Logger config
logger.add(logger.transports.Console, {colorize: true, timestamp: true});'SocketIO > listening on port ' + port);

io.on('connection', function(socket){
    console.log('a user connected');

my APP url for laravel is


My client site has this in my layout file

<script src="/"></script>
    var socket = io('http://localhost:3000');

I do a vagrant ssh and in my project folder i run this

node server.js

and it says

2015-05-10T09:31:21.161Z - info: SocketIO > listening on port 3000

i refresh my website and in console it says

ERROR Uncaught ReferenceError: io is not defined

in my URL i have this: Can anyone see what im doing wrong here :)?

Please sign in or create an account to participate in this conversation.