Revert "Revert "re connect if server droped the connection""

This reverts commit f84672dc52e3ebfdaa44bc5e8608c0291b5bce61.
fix segfault