javagrizzly

Sporadic 502 errors from java web application running on Grizzly


We are getting sporadic 502 errors from our web application; we can reproduce this by repeating the same call multiple times: at the 8th-12th time it hangs for ~30 seconds and then returns a "502 Proxy Error" html.

We ruled out this being an AWS or Apache problem by logging on one affected machine and calling the application directly on localhost:8080 with curl; after some calls, we get:

* Recv failure: Connection reset by peer
* stopped the pause stream!
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

Looking at application logs, it seems that the problematic calls never reach the application (they are never logged).

The web application is Java based, using Grizzly container (org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.25.1).

EDIT: the 30 seconds duration of hanging calls seems to be the keepAlive property of NetworkListener (https://javaee.github.io/grizzly/httpserverframework.html).

EDIT 2: the problem can be reproduced only by repeatedly calling APIs using an AsyncResponse; calling other endpoints does not trigger this behaviour.


Solution

  • Solved: upgrading to Jersey 2.26 solved the problem, although I did not understaind why it happened.