Exception in websocketpp and crashing

1,228 views
Skip to first unread message

vasakris

unread,
Jan 23, 2015, 8:22:23 AM1/23/15
to webso...@googlegroups.com
Hi

I am getting "terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'" exception during some performance test..

I have attached complete backtrace. 

I have added catch block while connecting and sending message, do i have to add try-catch block anywhere else still?

     try{
                client::connection_ptr con = client.get_connection(uri,ec);

                con->set_open_handler(websocketpp::lib::bind(&call::on_open,this,websocketpp::lib::placeholders::_1));
                con->set_fail_handler(websocketpp::lib::bind(&call::on_fail,this,websocketpp::lib::placeholders::_1));
                con->set_close_handler(websocketpp::lib::bind(&call::on_close,this,websocketpp::lib::placeholders::_1));
                con->set_message_handler(websocketpp::lib::bind(&call::on_message,this,websocketpp::lib::placeholders::_1,websocketpp::lib::placeholders::_2));
                client.connect(con);
        }
        catch (...){
                TRACE_MSG("ERROR: could not connect ");
                return;
        }

       try{
                client.send(m_hdl,msg,websocketpp::frame::opcode::text,ec);
        }
        catch(...){
                TRACE_MSG("ERROR.. cannot send message");
                return 0;
        }

Regards
vasakris




boost_exception.txt

Peter Thorson

unread,
Jan 23, 2015, 8:36:04 AM1/23/15
to vasakris, webso...@googlegroups.com
Hi vasakris,

Which version of the library are you using?

This looks similar to an issue with an invalid state exception being thrown in the library core. This could be confirmed by wrapping endpoint::run / io_service::run with try/catch and printing the exception’s message/code. This particular exception was very hard to catch and gracefully restart so the latest version (develop branch versions from the past month or so as well as the 0.5.0 release) have restructured the core state machine to not throw any exceptions that could bubble out of endpoint::run.

My first suggestion (if you haven’t already) would be to upgrade to 0.5 and see if that fixes it. If you are using 0.5 or a recent develop branch then we can dig a bit more.

In general, any of the client facing API methods (like get_connection, send, etc) that accept an error code by reference will not throw exceptions (except those that might be caused by system calls like malloc failures).

Peter

--
You received this message because you are subscribed to the Google Groups "WebSocket++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to websocketpp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<boost_exception.txt>

vasakris

unread,
Jan 23, 2015, 8:53:16 AM1/23/15
to webso...@googlegroups.com
Hi

I am using 0.3.0 (WebSocket++ (0.3.0))

Ok i will upgrade to 0.5.0 and try once, thank you :)

Regards
vasakris

vasakris

unread,
Jan 23, 2015, 12:19:47 PM1/23/15
to webso...@googlegroups.com
Hi

I tried with 0.5.0 version, got exception again. I enclosed, but couldn't catch exception..

                  try{
                        client.init_asio();
                        client.start_perpetual();
                        m_thread.reset(new websocketpp::lib::thread(&client::run, &client));
                    }catch(...){
                        TRACE_MSG("ERROR... sip_client run failure");
                        exit(1);
                    }
 
This exception is coming, when i have more than 1000 websocket connections..

Regards
vasakris

On Friday, 23 January 2015 18:52:23 UTC+5:30, vasakris wrote:

vasakris

unread,
Jan 24, 2015, 9:05:23 AM1/24/15
to webso...@googlegroups.com
Hi

I wrote thread block and captured exception.

void startClient(client *c)
{
        try{
                c->run();
        }catch(std::exception& e){
                std::cout<<"exception... "<<e.what()<<std::endl;
                exit(1);
        }catch(...){
                std::cout<<"ERROR.. exception caught"<<std::endl;
                exit(1);
        }
}

Getting exception "cancel: Bad file descriptor".
I ran many times and observed, that exception is coming when i open around 1017 open websocket connections.

 I am using boost library version "boost_1_56_0".

Regards
vasakris



On Friday, 23 January 2015 18:52:23 UTC+5:30, vasakris wrote:

Peter Thorson

unread,
Jan 24, 2015, 9:22:29 AM1/24/15
to vasakris, webso...@googlegroups.com
It sounds like your process is running out of file descriptors. Linux typically allows ~1024 by default. You can change these default values using OS level tweaking to allow more file descriptors (each socket needs one). Look at your OS documentation to determine what config needs to be set to do that.

As for the exception… this error should be delivered in a more graceful way, I’ll look into making that happen.

vasakris

unread,
Jan 24, 2015, 9:28:21 AM1/24/15
to webso...@googlegroups.com
Hi peter,

Yes, just checked this page

yes, i increased now ulimit for ports, it is working fine now .. :)

Thanks a lot for support.

Regards
vasakris

On Friday, 23 January 2015 18:52:23 UTC+5:30, vasakris wrote:

vasakris

unread,
Jan 24, 2015, 9:32:07 AM1/24/15
to webso...@googlegroups.com
Hi

And one more thing, how many successful websockets connections can be opened using websocketpp per second? 

Regards
vasakris

On Friday, 23 January 2015 18:52:23 UTC+5:30, vasakris wrote:

Peter Thorson

unread,
Jan 24, 2015, 10:46:01 AM1/24/15
to vasakris, webso...@googlegroups.com
Depends on your tcp accept backlog settings, your hardware & machine load, network conditions, etc. The last time I did mass connection stress testing I was able to get at least 4000/sec on a 2.8Ghz i7-860 on a dedicated local gigabit network.

Reply all
Reply to author
Forward
0 new messages