I'm currently implementing socket.io into my node.js/express application.
On the server side I have the following code -
var httpServer = http.createServer(app);
var io = require('socket.io')(httpServer, { resource: appSettings.VirtualDirectory + 'socket.io' });
httpServer.listen(Port);
And on the client side I have -
_connection = require('socket.io-client')(this._serverUrl, { query: "token={usersauthtoken}", path: "/" + (window.location.pathname.split('/').slice(0, -1).join('/') + '/socket.io').substring(1) });
This works fine without IISNode in the mix but once I deploy out to our staging server this is where the problems start to occur.
With the application placed at the root of IIS with no virtual directory the client shows the following error -
WebSocket connection to 'wss://OurStagingServer.com/socket.io/?token=eyJhbGciQDiJWJzI1Ni…I9vFloGOskkTGyQErYRtz6E&EIO=3&transport=websocket&sid=naKugwkujh6i_v3rAAAA' failed: Error during WebSocket handshake: Unexpected response code: 400
However, it does appear that the connection is actually made, and the client is picking up events emitted from the server.
With a virtual directory in the mix, I the client is requesting the correct url -
https://OurStagingServer.com/VirtualDirectory/socket.io/?token={token}
but is receiving 404's and the logs from express.js show that it is receiving the request but it looks like it is just looking for a static file which it obviously can't find and then giving up and returning the 404 response.
Only being able to deploy in the root directory is not an option, and I wouldn't be happy to do so anyway without understanding what is causing the error shown.
I've followed IISNode instructions to disable websockets in the web.config file (Apparently to stop IIS 8 from using its own implementaion?)
I should also say that I am using Express 4, with the latest versions of socket.io and IISNode.