I'm writing a Websocket client in Java, using javax.websocket API, and org.glassfish.tyrus
as the implementation.
Everything usually works, but sometimes, when I'm receiving very large strings, the connection closes with a mysterious 'Illegal UTF-8 Sequence' as the close reason.
log.info("Ws closed cuz: "
+ reason.getCloseCode() + " , "
+ reason.getReasonPhrase() + " , "
+ reason.toString());
Output:
INFO: Ws closed cuz: NOT_CONSISTENT , Illegal UTF-8 Sequence ,
CloseReason[1007,Illegal UTF-8 Sequence]
I'm guessing that either the string was too large, or the string contained any characters which aren't UTF-8 compatible.
Is there a way to get any more info on the actual string / packet / frame which causes this issue? Or, if there's a way to tell tyrus to ignore any encoding issues and just pass me the raw string and let me handle it?
If not, is there another java websockets client which does the bare bones work of transmitting the strings over socket and doesn't do any validation, and just lets me handle the responses?
Appreciate any feedback.