Forcing socket.io to use xhr-streaming
Is there a way to force socket.io not to use websockets, but xhr-streaming? Our loadbalancer does not let websocket connections through, so I would like to switch the communication protocol to xhr-streaming.
shooting from the hip here, haven't tested this idea:
in https://github.com/NarrativeScience/Log.io/blob/master/src/server.coffee, around line 202, socket io is being set up (io.set 'log level', 1 is one of those lines). You could try adding
io.set 'transports', [
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]
which should prevent socketio from using websockets. The default transports socket.io uses are websocket, htmlfile, xhr-polling, and jsonp-polling. This might already be something you can set in log.io's configs, I'll defer to @msmathers if this is even a good idea.
You can also check out https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO#recommended-production-settings and https://devcenter.heroku.com/articles/using-socket-io-with-node-js-on-heroku
Yes. I changed it directly in my production version in lib/server.jsin line 385. So the code there now looks like this:
WebServer.prototype.run = function() {
var _emit, _on,
_this = this;
this._log.info('Starting Log.io Web Server...');
this.logServer.run();
io = io.listen(this.http.listen(this.port, this.host));
io.set('log level', 1);
io.set('origins', this.restrictSocket);
io.set('transports', [
'xhr-polling'
]);
this.listener = io.sockets;
Seems to work. And yes, should be part of the web_server.conf.
@msmathers: Will there be any improvement at all at the moment. I think the thing people are wating on the most is the reactivation of the log history...