fix tis not closing socket on error
better reconnect handling