diff --git a/lib/client.js b/lib/client.js index 786eae6..ae97170 100644 --- a/lib/client.js +++ b/lib/client.js @@ -40,6 +40,11 @@ Client.prototype.connect = function(options, callback) { self.emit('connect'); }); + // Chromecasts silently drop idle connections. Without SO_KEEPALIVE + // the OS never probes, so a dead socket looks alive until the next + // write hangs on the caller's own timeout. + this.socket.setKeepAlive(true, 10000); + this.socket.on('error', onerror); this.socket.once('close', onclose);