Don't hang forever if websocket transport fails to connect

- Properly handle failures in PerformConnect
- Added functional test to verify behavior

#2168