Don't encode the message twice
Try reconnecting when disconnected or on error
Remove scroll event handling