Set up the connected handler before connect