log.io icon indicating copy to clipboard operation
log.io copied to clipboard

Forcing socket.io to use xhr-streaming

Open jochenonline opened this issue 12 years ago • 2 comments

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.

jochenonline avatar Jun 11 '13 06:06 jochenonline

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

wescleveland avatar Jun 11 '13 22:06 wescleveland

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...

jochenonline avatar Jun 12 '13 06:06 jochenonline