Deploying my app on Heroku breaks websockets protocol.
It works on localhost, not on Heroku. In browser, I get :
WebSocket connection to 'wss://node-omi.herokuapp.com/socket.io/?EIO=2&transport=websocket&sid=*' failed: Error during WebSocket handshake: Unexpected response code: 503
On the server side, I get in logs:
2014-08-12T15:05:24.761611+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/socket.io/?EIO=2&transport=websocket&sid=****" host=node-omi.herokuapp.com request_id=* fwd="*" dyno=web.1 connect=3ms service=3ms status=503 bytes=864
This is a part of my server script:
var express = require('express'),
http = require('http'),
socket_io = require('socket.io');
var app = express(),
server = http.Server(app),
io = new socket_io(server).of('/test');
io.on('connection', this.connection.bind(this));
app.get('/client.html', function(req, res, next) { ... });
app.use('/', express.static(__dirname + '/public', {'index': ['index.html']}));
server.listen(process.env.PORT || 5000);
What's wrong with my code ? Does anyone succeed in building a socket.io server with Express 4.8.3 and Socket.io 1.0.6 ? The socket works with polling, but I really need websockets to work. Thanks for replies.