[DEV-368] Reconnects stop after a JSON-RPC server is down for a while

I always hated the reconnection logic that I had originally written, and since this bug was needlessly difficult to find, I felt a refactor was necessary. 

I've been extra careful about the logic and tested it as thoroughly as I can, so please review this for anything that is obviously wrong. 

It would be nice if we could replicate the circumstances of the original bug in a testing environment. This is where a integration test setup would be useful.