Javascript agent to connect server