Added a try-catch to the WebSocket transport send.

- This helps catch errors that can be thrown from a websocket being in an invalid state.
- Also added a test to verify that we catch errors thrown by a socket send.

#2582