[jetty-users] connection.close() immediately after connection.send(String)
I have a WebSocket that sends a rather large message immediately before closing the connection. It was working fine when I was sending small strings, but lately I've been seeing the connection close (on the client side) with a 1006 code. The strange part is that when I put a breakpoint on the close() call (on the server side) to create a brief delay before the close, everything works just fine. This leads me to infer that the send is not completing before the close call occurs.
I have been operating under the assumption that a call to connection.send does not return until the
message is fully sent. The pattern I described above implies that the send is instead proceeding asynchronously, and the client is receiving a Close frame before it has received all of the message frames. Might this be the case? If so, is there any mechanism for ensuring that all pending frames are sent before closing the connection?
Thanks for your continued advice and support,