[GH-ISSUE #80] Forcing socket.io to use xhr-streaming #61

Open
opened 2026-02-26 05:31:12 +03:00 by kerem · 2 comments
Owner

Originally created by @jochenonline on GitHub (Jun 11, 2013).
Original GitHub issue: https://github.com/NarrativeScience-old/log.io/issues/80

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.

Originally created by @jochenonline on GitHub (Jun 11, 2013). Original GitHub issue: https://github.com/NarrativeScience-old/log.io/issues/80 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`.
Author
Owner

@wescleveland commented on GitHub (Jun 11, 2013):

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

<!-- gh-comment-id:19295493 --> @wescleveland commented on GitHub (Jun 11, 2013): 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 ``` coffeescript 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
Author
Owner

@jochenonline commented on GitHub (Jun 12, 2013):

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

<!-- gh-comment-id:19308305 --> @jochenonline commented on GitHub (Jun 12, 2013): Yes. I changed it directly in my production version in `lib/server.js`in `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...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/log.io-NarrativeScience-old#61
No description provided.