Try to reconnect socket if connection is closed.

Fixes #19