In my Meteor app, I am making outbound HTTP GET requests on an interval like such:
Meteor.setInterval(function () {
try {
var request = Meteor.http.call("GET", <url>, {
params: <params>,
timeout: <timeout>
});
}
catch (err) {
console.log(err);
request = undefined;
}
if (request.statusCode === 200) {
// handle the response
...
}
}, 10000);
If I let this run for a few minutes, I start getting errors logged to console via the catch
block: Error: socket hang up
.
What is causing these errors and how can they be mitigated? According to this SO post, the request needs to be told to .end();
, but I'm not sure if this is correct or how to do this in Meteor. Thanks!