libwebsockets icon indicating copy to clipboard operation
libwebsockets copied to clipboard

LWS_CALLBACK_EVENT_WAIT_CANCELLED received with no lws_cancel_service called?

Open bethebest0622 opened this issue 2 years ago • 1 comments

I am using libwebsockets to build connection with ws server, and receive data from server (Binance)

after i built connection, I got these event type regularly (every several minutes):

LWS_CALLBACK_GET_THREAD_ID
LWS_CALLBACK_EVENT_WAIT_CANCELLED
LWS_CALLBACK_CLIENT_RECEIVE_PONG

I read the header, for type LWS_CALLBACK_EVENT_WAIT_CANCELLED, it said: it's a callback of lws_cancel_service

but i never call this function. below is my service function:

  while (true) {
    try {
      lws_service(ctx_, 0); 
    } catch (std::exception &e) {
      EE("<CRYPTO_websocket::enter_event_loop> Error ! %s", e.what());
    }   
  }

after some LWS_CALLBACK_EVENT_WAIT_CANCELLED comes, the connection is broken.

so, is there anything i can do to avoid this? to make the connection stable and long? thanks a lot

bethebest0622 avatar Mar 06 '23 10:03 bethebest0622

Since it's based on binance example, it will be using compression... it sounds like a bug with handling PING / PONG inside a compressed link. EVENT_WAIT_CANCELLED is not what it sounds like, "cancelling the wait" is event loop-speak for waking from sleep to handle something (and then go back to the event wait sleep).

lws-team avatar Mar 06 '23 11:03 lws-team