express.io icon indicating copy to clipboard operation
express.io copied to clipboard

getting started express.io first simplest example

Open xetum opened this issue 8 years ago • 1 comments

I'm trying this simple example:

Server:

app = require('express.io')() app.http().io()

app.io.on('connection', function(socket){ console.log('connection') })

app.listen(50000)

Client:

var io = require('socket.io-client').connect('http://localhost:50000')

io.on('connect', function (sock) { console.log("socket connected") })

Neither 'connection' nor 'socket connected' appears in nodejs console

However separate express and socket.io server works like a charm:

var app = require('express')() var http = require('http').Server(app) var io = require('socket.io')(http)

io.on('connection', function(socket){ console.log('connection') })

http.listen(50000)

xetum avatar Apr 27 '16 14:04 xetum

I've been having the same issue, my server wont run at all, did you manage to solve it ?

AbdullahKhdir avatar Nov 17 '22 10:11 AbdullahKhdir