You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like this should work, though it's a bit hacky:
varForeverAgent=require('request/node_modules/forever-agent');// Set inactive socket timeout by shimming createConnectionvarcreateConnection=ForeverAgent.prototype.createConnection;ForeverAgent.prototype.createConnection=function(){varsocket=createConnection.apply(this,arguments);socket.setTimeout(Config.foreverAgent.timeout);returnsocket;};
Would be nice if this were exposed via agentOptions.timeout. Open to a pull request?
For posterity, looks like socket.setTimeout is a no-op in that you have to close the socket yourself. Here's the working code I ended up with:
varForeverAgent=require('request/node_modules/forever-agent');// Set inactive socket timeout by shimming createConnectionvarcreateConnection=ForeverAgent.prototype.createConnection;ForeverAgent.prototype.createConnection=function(){varsocket=createConnection.apply(this,arguments);socket.setTimeout(Config.foreverAgent.timeout||0,socket.end.bind(socket));returnsocket;};
It looks like we're going to need per-service (host:port) timeouts though, so I'll need to fork forever-agent (and submit a pull request), will update here.
What would be the best way to call socket.setTimeout?
This would be from the request level, i.e.,
The text was updated successfully, but these errors were encountered: