简体   繁体   中英

Websocket implementation of Tomcat 8.0.33 doesn't throw an IOException immediately when sendText() method is called(server side)

I am using Apache Tomcat 8.0.33.
I was going through Java documentation about RemoteEndpoint.Basic which says that sendText(String text) blocks until all of the message has been transmitted.
But I noticed that when the client loses internet connection and sendText() method is called on the server side, it doesn't thrown an IOException immediately and the method returns normally.
IOException is thrown later and the onError() method is called.
Is this a normal behaviour? Shouldn't the sendText() method block until all the message has been transmitted successfully or throw an IOException immediately if there's any problem?

Yes, this behavior is normal.

Depending on how the client disconnects, there server might not know and the message will sit in the network buffer until the network stack figures out that the client has gone away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM