Tweaked WS connection to use variables for hostname