HTTP clients can be infuriating in that they generally work without a hiccup; until they don’t!
I recently wrote a utility to receive and then save streamed Bid/Ask data from OANDA; called OandaSink. It wasn’t rocket science—some six hundred lines in all—so I turned it on and the program didn’t skip a beat for three solid weeks. Then, for some unknowable reason, the server forced a disconnect and all of my lovely retry / reconnect logic didn’t do what it was supposed to.
The problem with communications code is that it’s fiddly, so what I needed was a better way to fiddle with it. Unfortunately, there are almost no tools to help . Indeed, I only know of one (well, now, two!). The problem with “Clumsy” (https://jagt.github.io/clumsy) is that even though the v0.2 code seems to work flawlessly it’s not quite designed address my rather simple need–to manually kill and then restore an HTTP connection. Therefore I decided to roll something of my own.
WaxOnWaxOff (https://github.com/squideyes/WaxOnWaxOff) does two things: it releases and then restores DHCP connections; just the thing to help me twiddle around with retry/reconnect. As soon as I got WaxOnWaxOff working it took about three minutes flat to find and fix the flaw in my OandaSink code. As every programmer knows, if you can replicate a bug, you can fix a bug.
Compile, run, and enjoy…