Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
miladiashe408156dIf I see this 10 minutes before, I wouldn't broke my computer with infinite API call
zemaitis3874156dThis is why api calls shoud happen in separate threads and results should reach main thread via callbacks. Main thread should never be blocked.
asgs10653156dSome of our Devs randomly pick some http lib and use the default configuration. And default configuration is to wait forever.
Entire Queue gets blocked and it keeps growing like Mountain
What most devs do wrong are 2 fundamental things:
2) exception and error handling
Usually a TCP connection cannot stay forever and if it does there is something very wrong. "Popping" timeouts here, there, everywhere is a nightmare of maintenance.
Abstract properly the HTTP client and set a global timeout with an option to override it (which should be used sparingly).
Coming back to exception handling... Close the connection properly in the timeout.
Otherwise you might end up in the situation that system A ends up with massive open connections spawned by B which has a timeout shredding the connections to A after timeout and not closing it properly...
Fun to debug. Especially when the dev sprinkled literally the timeouts seemingly generated by a random number all across the codebase.