jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Server becomes unresponsive (seems to be related to using WebSockets)

Open nafets1234 opened this issue 7 years ago • 9 comments

I am running an application based on Jetty and since release 9.4.15.v20190215 I am experiencing issues with the server becoming unresponsive after a while. With 9.4.14.v20181114 everything was still working fine.

After doing a little research, I think I have a hunch where the issue might lie. When I modified my pom.xml to include the 9.4.15 version for all Jetty libraries except for the Jetty websocket-server, I was able to toggle the issue occurring by switching between the 9.4.14 and 9.4.15 for websocket-server.

So I had a look at the modifications that were done from 9.4.14 to 9.4.15 and noticed that WebSockerServerFactory now also implements WebSocketSessionListener. In a quick and dirty attempt, I removed this implementation again as attached below. Then the server did reproducably not get unresponsive anymore. Of course this is probably breaking Jetty's functionality somewhere else, but it might give a clue, where the issue resides.

The issue still exists with the recently released 9.4.18.

I included a Jetty server dump as well.

If any additional information is missing, please do not hesitate to ask back.

Thank you in advance, Stefan

serverdump.txt

WebSocketServerFactory.diff.txt

nafets1234 avatar May 01 '19 10:05 nafets1234

Duplicate of #3550 - please upgrade to fixed version 9.4.18.v20190429

joakime avatar May 01 '19 10:05 joakime

No, it is still occurring in 9.4.18.v20190429. See attached serverdump.txt file.

nafets1234 avatar May 01 '19 10:05 nafets1234

When you hit this "becomes unresponsive" state, have you hit a variety of endpoints on your server as a test? Hit a websocket endpoint. Hit a servlet endpoint. Hit a static resource endpoint. Hit a bad resource that should result in an error.

What happens in each case?

joakime avatar May 01 '19 10:05 joakime

Based on your serverdump.txt your server is alive, happy, and can handle connections just fine. However, since you captured the following ...

|  |  +> 22 qtp790229674-22 WAITING 5
|  |  |  +> sun.misc.Unsafe.park(Native Method)
|  |  |  +> java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
|  |  |  +> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
|  |  |  +> org.eclipse.jetty.util.SharedBlockingCallback$Blocker.block(SharedBlockingCallback.java:219)
|  |  |  +> org.eclipse.jetty.websocket.common.BlockingWriteCallback$WriteBlocker.block(BlockingWriteCallback.java:90)
|  |  |  +> org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.blockingWrite(WebSocketRemoteEndpoint.java:107)
|  |  |  +> org.eclipse.jetty.websocket.common.WebSocketRemoteEndpoint.sendString(WebSocketRemoteEndpoint.java:385)
|  |  |  +> net.myapp.javacommon.AbstractRemoteEndpoints.sendMessage(AbstractRemoteEndpoints.java:75)

That seems to be related to Issue #2061

joakime avatar May 01 '19 21:05 joakime

You are right, servlet endpoints are still working. Static resources I am not using in my application. Bad resources are handled by a servlet which is also working. As I am heavily relying on WebSockets this was not obvious from the start.

What strikes me though is that I am having this issue only since 9.4.15. Before I did not have any issues with this and I did not change anything in my application. Also while I am using Spring, my project only includes only the following libraries:

image

So not the library in question in the other issue.

nafets1234 avatar May 05 '19 21:05 nafets1234

Do you call session.disconnect() somewhere? I had similar problems and I call that method #3581

2beers avatar May 11 '19 01:05 2beers

@2beers Thanks for the input. No, in fact I am not closing the sessions ever.

nafets1234 avatar May 12 '19 10:05 nafets1234

Good news, the issue got resolved with version 9.4.19. In that version and 9.4.20 everything is working fine, downgrading back to 9.4.18 brings the issue back.

nafets1234 avatar Aug 15 '19 19:08 nafets1234

@nafets1234 thank you for the update

joakime avatar Aug 15 '19 19:08 joakime