Socket.io 1.0.0-pre Authorize (Handshake data)
So, I know the handshake data is now socket.request, but I am not seeing my query as I would expect:
Client (actually a server using socket.io-client): var socket = socketIoClient('https://example.com:443/?key=12345');
Server: socketIoObject.use(function(socket, next) { console.log('socket.request: ' + util.inspect(socket, {depth : null})); });
No where in the socket object do I see my query key. I would like to use this key for authorization. Where can I find it?
@cloudcash this is a good find. I just submitted a pull request that should resolve this problem here https://github.com/LearnBoost/socket.io-client/pull/656.
Once it is merged, you should be able to get the query stuff at socket.request.query.
@cloudcash Here's an ammendment. My PR should make the query accessible by parsing socket.request.url.
Thanks, I'll give it a shot :+1:
@cloudcash did it work out? :) Wondering if we can close the issue.
Hello, same problem here, using angular-fullstack. I checked lib/index.js file but I couldn't find parsed.href. Any idea ?
You can use this way Client: var socket = io.connect('http://localhost:3000', { query: "key=12345" });
Server: io.set('authorization', function (handshakeData, callback) { callback(null, true); });
io.sockets.on('connection', function(socket){ var key = socket.handshake.query.key; // your key });
Thank you for your answer ! Key is undefined this way, unfortunately. You can see this stackoverflow question for something I tried: http://stackoverflow.com/questions/26993447/socket-io-handshake-fails-on-site-but-not-on-localhost