automatic reconnect. handle more message types.