Automatically detecting hostname when creating websocket connection rather than hard coding to localhost