iisnode
iisnode copied to clipboard
Socket.io response code 200 instead 101
Hi!
When I try to use socket.io and Express with IISnode is have a problem, websocket connection return status 200 instead 101.
Socket.io version: 1.4.5 IIS node: 0.2.21
server code:
var express = require('express');
var app = express();
const port = process.env.PORT || 8080;
// socket.io ver 1.4.5
var server = require('http').Server(app);
var io = require('socket.io', {path: '/api/socket.io'})(server);
server.listen(port);
io.on('connection', function (socket) {
socket.emit('test', { hello: 'world' });
});
app code (angular 2):
var address = 'http://xxx.xxx.xxx.xxx:8080/'; // ip address
var socket = io.connect(address, {transports: ['websocket'], path: '/api/socket.io'});
socket.on('test', (data) => {
console.log(data, '<-- socket data');
})
web.config
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
<!-- <add name="iisnode-socket.io" path="index.js" verb="*" modules="iisnode" /> -->
</handlers>
<rewrite>
<rules>
<rule name="LogFile" patternSyntax="ECMAScript">
<match url="socket.io"/>
<action type="Rewrite" url="index.js"/>
</rule>
<rule name="api">
<match url="/*"/>
<action type="Rewrite" url="index.js"/>
</rule>
</rules>
</rewrite>
<iisnode
devErrorsEnabled="true"/>
<webSocket enabled="false" />
</system.webServer>
</configuration>
And, then I run this app as static on same server I've got 200 status of response and this error in console:
WebSocket connection to 'ws://xxx.xxx.xxx.xxx:8080/api/socket.io/?EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 200
What I do wrong?
Hi Tomek/Carl, Having the same issue with the new version of socket.io (1.4.6). Did you make it finally working? If yes, can you share your solution?
Thanks, Yuri.
Guys,
Same issue here even with the 1.5.x
Any updates?
I'm also having the same problem...
I am using socket.io 2.0.2 and iisnode 0.2.21 and also having the same problem. Has anyone made this work?
same here 2.0.3 but when downgrades to 1.3.5 everything fine. Interesting thing noticed: when upgrades back to 2.0.3 it still works fine. I have confirmed this several times even on prod sever.
Same issue here on v4.3.1. I am using ELB on AWS and am wondering if it is not relaying properly (?)