Properly resubscribe on reconnection.

Improve error handling by catching and logging exceptions.