-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Sporadic failures to shutdown the server (gracefully) #106
Comments
Does not seem to be a problem in the example app when I move it between background and foreground; but it does happen in my app when Google.Play purchase flow is started (the RN app itself moves to background state then, and sometimes the server fails to stop, never exiting the main loop on Lighttpd site). I wonder whether it is related to a bug fixed in the latest Lighttpd v1.4.76. |
No, v1.4.76 does not help. A note for myself, on what I figured out so far happens during a failed shutdown attempt, in Lighttpd core:
|
Hi @gstrauss , if you have a free moment, will you help me out here, please? After tracing stuff a bit further I figured out this:
At this point, it feels like a bug in Lighttpd to me, I guess here once connection is marked as errored because of Or... do I misunderstand something here? |
Yeah, I have verified that changing the if-block from if (graceful_expire) {
connection_set_state_error(r, CON_STATE_ERROR);
changed = 1;
} into if (graceful_expire && r->state != CON_STATE_CLOSE) {
connection_set_state_error(r, CON_STATE_ERROR);
changed = 1;
} solves the problem for me — in case when the server does not gracefully shutdown rapidly, it successfully shuts down after the expected 8 + 5 seconds timeout. |
Thank you for the detailed troubleshooting. I have to ruminate on this a bit. |
Instead of your suggested patch, my initial take (untested) is that |
Since the intent is that |
|
|
@gstrauss your variant sure works as well, though I am not sure why to set Another thought I got — in this scenario, when we arrive to Also, I noticed that |
CON_STATE_ERROR triggers various request/connection cleanups prior to transition to CON_STATE_CLOSE. If already in CON_STATE_CLOSE, setting changed and calling Near the top of
As above, CON_STATE_ERROR does some things prior to transition to CON_STATE_CLOSE, e.g. calling
server.feature-flags documents |
You are right, with the patch in place, the server shuts down within a second after the graceful shutdown expiration. My bad. |
Thanks for confirming. I have committed the following patch with your patch to fix the issue here and a small change to more quickly close connections after the graceful shutdown timeout has expired and the connection state is CON_STATE_CLOSE. There may still be a 1 second delay after graceful shutdown timeout has expired. This allows for lighttpd to set CON_STATE_ERROR to trigger sending
|
I should note that the issue you are seeing here in #106 is a bug in lighttpd, but that bug was exposed due to your clients ignoring the |
By clients do you mean the HTTP client on the other side of connection that fails to close gracefully? I should investigate it… though, in my case the client connecting to the server is the Android’s WebView, not some custom client I’ve implemented myself; but the problem occurs when I’m moving my app into background, sounds like it may interfere with normal handling of connections by WebView. |
Yes, the HTTP client on the other side of the connection. In the scenario you describe, are the clients receiving the Overall, my question is: What are the reason(s) that the client connections are not being closed prior to the graceful shutdown timeout in lighttpd? |
I have no idea. I guess, some bug on the client side, but for now just falling back to non-graceful shutdown is good enough for me. I'll return to investigating it at a better time later 🤷♂️ |
avoid changing connection state to back to CON_STATE_ERROR if the state has already reached CON_STATE_CLOSE, which may result in the graceful shutdown timeout not taking effect for that connection if the client does not notice the socket shutdown(fd, SHUT_WR). (thx birdofpreyru) x-ref: "[Android] Sporadic failures to shutdown the server" birdofpreyru/react-native-static-server#106
No description provided.
The text was updated successfully, but these errors were encountered: