Skip to content
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

The beast Server Exits frequently #2859

Open
vtharmalingam opened this issue Apr 25, 2024 · 3 comments
Open

The beast Server Exits frequently #2859

vtharmalingam opened this issue Apr 25, 2024 · 3 comments

Comments

@vtharmalingam
Copy link

1.84

The application I developed is frequently exiting, causing me to lose "sessions" stored in "shared_state." These sessions are crucial for the app, and such exits pose a significant problem of user's discontinuity. Although I enabled boost::stacktrace, these exits do not qualify as crashes, so it doesn't provide much help. It seems to me (with my limited knowledge) that it's a session issue between the client and server, and a typical closure of a session could potentially bring down the entire app. Perhaps, the io_context exits due to completed work.

Crash Scenario 1 and the Console message

write: The I/O operation has been aborted because of either a thread exit or an application request

Crash Scenario 2 and the Console message

read: An existing connection was forcibly closed by the remote host
[on_write]: exception caught: bad_weak_ptr
read: An existing connection was forcibly closed by the remote host

I read this stackoverflow thread and it says "cancellation of the read invalidates future writes on the websocket.".

Given my environment being Windows, maybe leveraging Structured Exception Handling (SEH) __try and __Error could be of any help at all, nor sure of what is the right way to leverage them.

Please provide guidance to ensure stability and robustness.

Thanks, in advance!

Regards,
Tharma

@ashtum
Copy link
Collaborator

ashtum commented Apr 25, 2024

write: The I/O operation has been aborted because of either a thread exit or an application request

This error suggests you might have a lifetime issue in your application, where an I/O object (such as a socket or resolver) has been destroyed while there was an outstanding async operation.

read: An existing connection was forcibly closed by the remote host
[on_write]: exception caught: bad_weak_ptr
read: An existing connection was forcibly closed by the remote host

Same is the case here, it seems you tried to access a weak_ptr unconditionally while the actual object has been destroyed, my guess is you are using weak_ptr where a shared_ptr is appropriate or having a flawed object hierarchy.

It's difficult to pinpoint the issue without additional details about your code.

@vtharmalingam
Copy link
Author

Thanks, @ashtum. Got it. I'll work on streamlining the code flow and share it over. It might take a little while though.

Additionally, I've noticed occasionally encountering the below type of error that leads to an exit.
Does that ring any bells? I suspect it's distinct from the errors we discussed earlier. Any insights on that?

read: The network connection was aborted by the local system

Thanks,
Tharma

@ashtum
Copy link
Collaborator

ashtum commented Apr 25, 2024

read: The network connection was aborted by the local system

Your server should be prepared for this kind of error (client connections might fail for all sorts of reasons). The server should close the socket and release all the resources associated with it. It seems you have a flaw in your code in that regard (either accessing a destroyed object or not checking the returned error code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants