Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Commented Issue: websocket_client - uncatchable exception when receive/close occurs [236]

$
0
0
Mentioned in a comment in https://casablanca.codeplex.com/workitem/177.

raffaeler wrote Fri at 6:41 AM [x]

Using 2.1.0 here.
I could not even catch the exception with websocket_exception nor "..."
When the receive is ongoing and the close is called, the rest sdk internal code crashes without any chance to catch the exception.

Stack trace of the error:
cpprest120d_2_1.dll!Concurrency::details::_ExceptionHolder::~_ExceptionHolder(void) Unknown
cpprest120d_2_1.dll!Concurrency::details::_ExceptionHolder::`scalar deleting destructor'(unsigned int) Unknown
cpprest120d_2_1.dll!std::_Ref_count_obj<struct Concurrency::details::_ExceptionHolder>::_Destroy(void) Unknown

WebsocketsTesterCpp.exe!std::_Ref_count_base::_Decref() Line 118 C++

WebsocketsTesterCpp.exe!std::_Ptr_base<Concurrency::details::_ExceptionHolder>::_Decref() Line 344 C++
WebsocketsTesterCpp.exe!std::shared_ptr<Concurrency::details::_ExceptionHolder>::~shared_ptr<Concurrency::details::_ExceptionHolder>() Line 611 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl_base::~_Task_impl_base() Line 1677 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::~_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >() Line 2367 C++
WebsocketsTesterCpp.exe!Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::`scalar deleting destructor'(unsigned int) C++
WebsocketsTesterCpp.exe!std::_Ref_count_obj<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Destroy() Line 944 C++
WebsocketsTesterCpp.exe!std::_Ref_count_base::_Decref() Line 118 C++
WebsocketsTesterCpp.exe!std::_Ptr_base<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Decref() Line 344 C++
WebsocketsTesterCpp.exe!std::shared_ptr<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::~shared_ptr<Concurrency::details::_Task_impl<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >() Line 611 C++
WebsocketsTesterCpp.exe!Concurrency::details::_PPLTaskHandle<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>,Concurrency::details::_ContinuationTaskHandleBase>::~_PPLTaskHandle<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>,Concurrency::details::_ContinuationTaskHandleBase>() Line 1588 C++
WebsocketsTesterCpp.exe!Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>::~_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>() Line 3769 C++
WebsocketsTesterCpp.exe!Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>::_ContinuationTaskHandle<web::experimental::web_sockets::client::websocket_incoming_message,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Concurrency::task<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > <lambda>(Concurrency::task<web::experimental::web_sockets::client::websocket_incoming_message>),std::integral_constant<bool,1>,Concurrency::details::_TypeSelectorAsyncTask>::`scalar deleting destructor'(unsigned int) C++
msvcr120d.dll!0fbc72bc() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr120d.dll]
msvcr120d.dll!0fbfe801() Unknown
msvcr120d.dll!0fbc7e8a() Unknown
msvcr120d.dll!0fbd75b3() Unknown
msvcr120d.dll!0fbf9ac1() Unknown
msvcr120d.dll!0fbd4257() Unknown
msvcr120d.dll!0fbd4123() Unknown
msvcr120d.dll!0fbd2bae() Unknown
msvcr120d.dll!0fc00f94() Unknown
kernel32.dll!76b0919f() Unknown
ntdll.dll!7718a22b() Unknown
ntdll.dll!7718a201() Unknown


Suggestions?
Comments: Basically I always listen, not just as a consequence of having sent something before. The StartReceiving is called within itself but it's not a recursive function because it's an asynchronous operation. If it was a synchronous operation this would be a simple for/while loop. Since I am always in receive mode, I want also to be able to quit. I tried two different ways: - cancelling the token (but it does not work, probably because it's not implemented as stated in the other thread) - closing the connection, but it throws even with all this exaggerated number of catches. BTW I also posted another thread related to not be able to unload the casablanca dll. I don't know if it's related to this one. Thanks for your comments/help. ``` void StartReceiving() { if (_onReceived == nullptr) return; try { raf_helpers::Trace(raf_helpers::make_string() << "Start receiving" << "\r\n"); client->receive().then([this](task<websocket_incoming_message> tmsg) { websocket_incoming_message msg; try { msg = tmsg.get(); } catch (const websocket_exception& e) { string errorMessage; // Connection has been closed errorMessage += string(e.what()); raf_helpers::Trace(raf_helpers::make_string() << errorMessage << "\r\n"); try { _onReceived(this, WebSocketReceivedArgs(wstring(begin(errorMessage), end(errorMessage)), true)); } catch (...) {} if (!_cts.get_token().is_canceled()) _cts.cancel(); return task_from_result(string()); } catch (...) { raf_helpers::Trace(raf_helpers::make_string() << L"Error while receiving" << "\r\n"); } return msg.extract_string(); }, _cts.get_token()).then([this](std::string body) { auto wbody = to_string_t(body); if (_cts.get_token().is_canceled()) { string errorMessage("isCanceled == true"); raf_helpers::Trace(raf_helpers::make_string() << errorMessage.c_str() << "\r\n"); try { _onReceived(this, WebSocketReceivedArgs(wbody, true)); } catch (...) {} evQuit.Set(); return; } raf_helpers::Trace(raf_helpers::make_wstring() << L"RX: " << wbody.c_str() << L"\r\n"); try { auto continueListening = _onReceived(this, WebSocketReceivedArgs(wbody)); if (!continueListening) { evQuit.Set(); return; } } catch (...) {} StartReceiving(); }); } catch (const websocket_exception& e) { string errorMessage("receive() error: "); errorMessage += string(e.what()); raf_helpers::Trace(raf_helpers::make_string() << errorMessage.c_str() << "\r\n"); try { _onReceived(this, WebSocketReceivedArgs(wstring(begin(errorMessage), end(errorMessage)), true)); } catch (...) {} evQuit.Set(); } catch (...) { string errorMessage("Error receiving"); raf_helpers::Trace(raf_helpers::make_string() << errorMessage << "\r\n"); try { _onReceived(this, WebSocketReceivedArgs(wstring(begin(errorMessage), end(errorMessage)), true)); } catch (...) {} evQuit.Set(); } } ```

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>