Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control io heartbeat interval and timeout via server configuration #86

Closed
vstirbu opened this issue Mar 9, 2015 · 5 comments
Closed

Comments

@vstirbu
Copy link
Contributor

vstirbu commented Mar 9, 2015

I would like to be able to configure the interval and the timeout of the underlying socket.io to accommodate scenarios with stricter requirements than the default values.

I have noticed that there is an undocumented configuration option logLevel that allows controlling the socket.io logging behaviour: https://github.com/incompl/cloak/blob/master/src/server/cloak/index.js#L93

However, I have noticed also #69 where the idea is not to have socket.io specific configurations.

So, what do you say about extending the server configuration with socket.io specific parameters, although heartbeat is not particularly tight to the specific transport...

My quick and dirty proposal is to add

io.set('heartbeat interval', config.heartbeatInterval);
io.set('heartbeat timeout', config.heartbeatTimeout);

right after logLevel.

@incompl
Copy link
Owner

incompl commented Mar 17, 2015

Does it work to do this?

cloak.run('http://localhost:8090', {
  'socket.io': {
    'heartbeat interval': 123,
    'heartbeat timeout', 456
  }
});

If so, I will update the documentation at https://github.com/incompl/cloak/wiki/ClientConfiguration accordingly.

@vstirbu
Copy link
Contributor Author

vstirbu commented Mar 19, 2015

The option for controlling the heartbeat on the client that I found in the socket.io documentation that works with cloak is the following:

cloak.run(url, {
   'socket.io': {
      heartbeatTimeout: 10000 // the value in ms
   }
});

However I'm not that familiar with how socket.io handles the heartbeat and if you can control the server behaviour from the client.

@incompl
Copy link
Owner

incompl commented Mar 20, 2015

I'm not clear on the details (seems like heartbeat settings are not in the latest version of Socket.io so they weren't in the documentation anymore) but I found this on Stackoverflow:

By default, a Socket.IO client will send a heartbeat to the server every 15 seconds (heartbeat timeout), and if the server hasn't heard from the client in 20 seconds (heartbeat interval) it will consider the client disconnected.

@vstirbu
Copy link
Contributor Author

vstirbu commented Mar 20, 2015

There is also this in the documentation on migrating to 1.x.

BTW, I have this branch with cloak running over socket.io 1.x, but don't know yet how to handle the heartbeat issue before making a PR.

@incompl
Copy link
Owner

incompl commented May 6, 2015

Implemented by #88

@incompl incompl closed this as completed May 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants