AlgoTrader / betfair-sports-api

Library is discontinued
MIT License
55 stars 15 forks source link

Unhandled 'error' event #8

Closed rowanu closed 11 years ago

rowanu commented 11 years ago

Occasionally I see this error when getting prices (usually after running for a while):

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: socket hang up
    at createHangUpError (http.js:1263:15)
    at CleartextStream.socketCloseListener (http.js:1314:23)
    at CleartextStream.EventEmitter.emit (events.js:115:20)
    at SecurePair.destroy (tls.js:907:22)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Any ideas what might cause this? Is there a way to catch these errors outside the betfair-sports-api library?

Thanks for the library!

AlgoTrader commented 11 years ago

It is the normal situation (although rare). It means the HTTPS connection was disconnected when the response was expected. There are many reasons why it may happen, some of them 1) remote end problems 2) network problems 3) sending HTTP request while remote end closing connection as idle. In most cases you cannot prevent such errors

AlgoTrader commented 11 years ago

After puting code like this

process.on('uncaughtException', function(err) {
  console.log(err);
});

you app will stop to exit on such exceptions

rowanu commented 11 years ago

Thanks for the work-around!