Skip to content

Instantly share code, notes, and snippets.

@ozten
Created December 15, 2012 00:05
Show Gist options
  • Select an option

  • Save ozten/4289776 to your computer and use it in GitHub Desktop.

Select an option

Save ozten/4289776 to your computer and use it in GitHub Desktop.
Connect to Socket.io from express code
// At the top of routes.js
var io = require('socket.io-client');
// Later
socket = io.connect('http://localhost:9714', {headers: {'X-express-to-socket-password': 'some secret string'}});
//or
socket = io.connect('http://localhost:9714', {'query': 'express-to-socket-password=some secret string'});
// In either case... all I see coming in at https://github.com/ozten/roomr/blob/master/server/sockets.js#L16 is
/*
authorization step
{ 'user-agent': 'node-XMLHttpRequest',
accept: '* / *',
host: 'localhost:9714',
connection: 'keep-alive' }
checking res.socket.encrypted
ATTEMPTING TO authenticate new connection {}
SESSION= {}
User is allowed? false
debug - authorized
info - handshake unauthorized
*/
// What I want is
/*
authorization step
{ 'user-agent': 'node-XMLHttpRequest',
accept: '* / *',
host: 'localhost:9714',
connection: 'keep-alive'
headers: {
"X-express-to-socket-password": 'some secret string"
}
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment