zaphoyd / websocketpp

C++ websocket client/server library
http://www.zaphoyd.com/websocketpp
Other
6.98k stars 1.97k forks source link

Bad Connection #579

Open sznczy opened 8 years ago

sznczy commented 8 years ago

I have a websocket client based on websocketpp downloaded from BTCC.com, and I would like to receive trading data with this solution.

The client is able to start and receive messages, but it always gives this message after 88 seconds of successful running:

websocket closed. [2016-09-04 12:15:20] [disconnect] Disconnect close local:[1000] remote:[1000] terminate called after throwing an instance of 'websocketpp::exception' what(): Bad Connection Aborted

I reported the issue to the BTCC.com, but they did not find any trouble in their system.

What should I do?

zaphoyd commented 8 years ago

A bad connection indicates that you tried to send (or perform some other operation) on a stale connection_hdl. i.e. a connection that was already closed, but you still have a handle around for. This often happens in multithreaded applications where a central list of connections is periodically updated and/or sent to. Its possible for an application to grab the list of current connections but for one of those connections to have closed (perhaps by another thread) by the time send is actually called.

Exactly how to deal with this error is application specific, but in a great many cases it is simply to catch it and ignore it. Perhaps open a new connection.

peipei1213 commented 4 months ago

https://stackoverflow.com/questions/78448626/webscoket-for-realtime-visualization-get-bad-connections

This is my problem, I also encountered this bad connection, could you guys give me some suggestions? Thank you very much. @zaphoyd @sznczy