Connection fixes

Now reconnects if the connection is interrupted during the sending of
events.