if you push notification1 (an error)
you push notification2 (a good one)

you sleep 5 seconds (because you are blocking on a queue and don't receive any messages for a while)
you check in and ask if everything is ok - the connection is closed by now, but the socket will say you have something to read.
so you try and read, and the socket says - forget it, the socket is closed (because you were supposed to read 4.5 seconds ago

so basically, you dropped notification2 on the floor. Which you would not have dropped if you hadn't slept the 5 seconds.

the read_if_connected ends up returning nil. so you basically know you dropped something, but are not sure what.


In production we we were just calling @connection.read instead of read_if_connected, and it would notice that the connection was closed and reopen it up. Since there was nothing on this connection to read, it would block us. very confusing.

I'm thinking I should pull this out into a pull request because that could really bite someone. (single or multi threaded)