Skip to content

Fix process abort when a server PING arrives during connection teardown#461

Open
marekl11 wants to merge 1 commit into
getnamo:mainfrom
marekl11:fix/on-ping-pong-abort
Open

Fix process abort when a server PING arrives during connection teardown#461
marekl11 wants to merge 1 commit into
getnamo:mainfrom
marekl11:fix/on-ping-pong-abort

Conversation

@marekl11

Copy link
Copy Markdown
Contributor

on_ping() replied to server PINGs with the throwing websocketpp send overload, unlike send_impl()/ping() which use the non-throwing error_code overload and guard on con_opened. If a PING lands while the connection is tearing down, websocketpp throws (invalid_state/bad_connection) on the asio network thread, which run_loop() did not catch, so it propagated to std::terminate -> abort and killed the whole process. Seen under connect/disconnect churn (reconnects, level transitions) in a packaged UE5 build.

on_ping() now mirrors send_impl()/ping(): only send when con_opened and use the error_code overload. run_loop() additionally wraps m_client.run() in a try/catch so no stray handler exception can ever take the process down.

@getnamo getnamo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix without try/catch. This is avoided in unreal modules in general.

on_ping() replied to server PINGs with the throwing websocketpp send overload,
unlike send_impl()/ping() which use the non-throwing error_code overload and
guard on con_opened. If a PING lands while the connection is tearing down,
websocketpp throws (invalid_state/bad_connection) on the asio network thread,
which run_loop() did not catch, so it propagated to std::terminate -> abort and
killed the whole process. Seen under connect/disconnect churn (reconnects, level
transitions) in a packaged UE5 build.

on_ping() now mirrors send_impl()/ping(): only send when con_opened and use the
error_code overload. run_loop() additionally wraps m_client.run() in a try/catch
so no stray handler exception can ever take the process down.
@marekl11 marekl11 force-pushed the fix/on-ping-pong-abort branch from d2b23ff to 6d1d3fd Compare June 19, 2026 21:17
@marekl11

Copy link
Copy Markdown
Contributor Author

Good point! dropped the try/catch. The PR is now just the on_ping change: send the PONG only when con_opened, via the non-throwing error_code overload (same pattern as send_impl()/ping()). That stops the throw at the source, so nothing escapes the io thread and the catch isn't needed. Force-pushed the revised commit.

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

Successfully merging this pull request may close these issues.

2 participants