extract connect func, reconnect on server conn close