Node.js restify with socket.io

Nick Sanders picture Nick Sanders · Oct 27, 2012 · Viewed 9.2k times · Source

Is it possible to run socket.io & restify on the same port like express & socket.io?

I did just like this but it didn't work

# server.coffee
restify = require 'restify'
socket  = require 'socket.io'

server = restify.createServer()

io = socket.listen server
server.listen 1337

when I try to connect to socket.io:

GET http://localhost:1337/socket.io/socket.io.js 404 (Not Found) 

Answer

amolbk picture amolbk · May 23, 2014

As suggested here by @jtomasrl and @zacheryph, this worked for me:

var server = restify.createServer();
var io = socketio.listen(server.server); //Note server.server instead of just server