websocketsocket.io

socketio websocket connection failed


WebSocket connection to 'ws://www.abc.com/socket.io/1/websocket/VKxqJC3PoXJ0DUbxgX8n' failed: Unexpected response code: 503

The browser console shows the above error of socketio websocket connection failed.

express code:-

server.listen(app.get('port'), function(){
  console.log("Express server listening on port " + app.get('port'));
});
var io = require("socket.io").listen(server);

Above works fine, on localhost.


Solution

  • Adding following code as part of server is needed for heroku.

    io.configure(function () { 
      io.set("transports", ["xhr-polling"]); 
      io.set("polling duration", 10); 
    });