add auto reconnect
add ping command
fix cleanup after disconnecting