My code sends a message and within 100 ms, the onClosed() gets called with CloseReason CLOSED_ABNORMALLY An unrecoverable IOException occurred so the connection was closed
31 Answer
Found out the issue.
The issue was in the message handler (onMessage()). While parsing the response into a json, there was a unhandled parsing exception. That caused an IOException to be thrown which caused the session to close. It is unintuitive that the session gets closed, while there is no meaningful indication that the IOException happened inside the onMessage(). Once i handled the exception, the session stays open.
0