Wiznet - gracefully handle out of sockets? #773
Replies: 1 comment
-
Posted at 2015-07-23 by @gfwilliams At the moment I'm afraid there isn't anything built-in. I should probably implement the Amazingly it doesn't seem to be listed as an event in the node.js docs despite being there, which is probably one reason I never implemented it. I'll add it to the bug list :) For now, you could actually look inside the CientRequest structure to see if it's managed to get a socket - the test will work even for 'unable to locate host' errors too. I think you should be able to do:
Other option is to make your own http get function that'd look a bit like:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-07-23 by DrAzzy
Is there any way to detect and handle the "out of sockets" error?
If you have a number of events that can trigger HTTP requests, it's easy to end up with enough happening in succession (if a few events happen at about the same time) that you run out of sockets (or that seems to be the case? It just happened to me when I made a few requests in rapid succession, and I don't think I was doing anything that would break it...). Is there a way to catch and handle this (ie, by waiting a few minutes and retrying)? Or is there a way to check how many free sockets there are?
Otherwise, it will be very hard to implement my current project, because it can generate http requests in response to a fairly wide variety of events, and it is very likely that these will sometimes happen in rapid succession (for example, when I open my door, I normally close it within a few seconds, since I have the A/C on...), and I don't want to have it missing events....
Beta Was this translation helpful? Give feedback.
All reactions