Open pratman opened 2 years ago
why is that required? calling code can catch exceptions thrown in async code like this https://github.com/crossbario/autobahn-cpp/blob/master/examples/caller.cpp
mmh ... wait .. maybe I'm confused .. other places in the session code do similar as you suggest:
aaah, ok: so the session code throws protocol errors, but uses setting the exception on a future in cases the application can / want to react to in a regular fashion.
so the actual Q is: in this specific case, the signature of the challenge sent by the client could not be verified by the router, and hence the router denies the client authentication.
this isn't a protocol error so ..
router didnt deny anything, send_message threw from any reason such as no transport. in any case application shouldnt crash. joining client is waiting on the .get() and should get the exception through the future (like everywhere else). only in this method is done incorrectly. i think real question is whether failing to send a message should crash an application
well, why would throwing an exception crash a program necessarily? just catch it? not sure, I'm not using c++ often these days, and these arcane styles;)
anyways, this code has the pattern I believe to be correct:
rethinking about the issue you posted: if a signature could not be verified, the WAMP openening handshake fails, and a completely new session and handshake must be performed (at the WAMP protocol level).
so that means, m_session_join should complete with error, but it is not a fatal error (like eg the router talking gibberish bytes ..)
Thanks for looking into this so quickly. This challenge handling happens within the asio context and exceptions thrown within these methods such as process_challenge cannot be caught by the application. The only way to signal such error from the context thread to the application is by using the futures, as done in the other methods. In process_abort as you mentioned above, the throws will also remain unhandled and lead to a crash.
Example of the stack:
VCRUNTIME140!_CxxThrowException+0x66 [throw.cpp @ 74]
YOURAPP!
m_session_join has to take the exception instead of throwing so connecting(and challenged) client can react on .get() instead of the whole application crashing from the unhandled exception (which is thrown inside of the asio_context loop).
one of the places with a possible fix:![image](https://user-images.githubusercontent.com/10516233/152797917-86fdc219-e398-49b0-9888-5f9aa22c9657.png)