We run a Node.js and Express application on Heroku that uses the ws library for realtime web sockets. Below is a screen shot of the numerous H15 timeout's that we are seeing.
I've read that Heroku terminates any idle connection after 55 seconds but our sockets send ping-pong back and forth every 5 seconds when the connection is open. A piece of the server code is below:
var _this = this;
this.server.on('connection', function(ws){
// check for a ping, respond with pong
ws.on('message', function(data){
data = data.toString('utf8');
if (data === PING) {
ws.send(PONG);
}
});
ws.on('close', function(err){
TL.logger.info('Socket closed: '+path);
_this.sockets = _.filter(_this.sockets, function(_ws){
return ws != _ws;
});
});
ws.on('error', function(err){
TL.logger.info('Socket error: '+path);
_this.sockets = _.filter(_this.sockets, function(_ws){
return ws != _ws;
});
});
_this.sockets.push(ws);
});
And here's a picture of client side socket in chrome:
Any idea's how to prevent the idle connection?
disclosure: I'm the Node.js platform owner at Heroku.
Are you seeing this on the client side? Or just the error-reporting dashboard?
I'd recommend focusing on reproducing the errors on at least one client, to see if there's actually any impact. Otherwise, you may be wasting time debugging false positives.
If you do decide to continue debugging, you may want to install a free papertrail / nodetime / new relic / strongloop addon to figure out exactly which requests are triggering the H15s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With