Bug fix: persistent reconnect after closing socket