zaphoyd / websocketpp

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

TSL not working: asio handle_timer error #632

Open goodxianping opened 7 years ago

goodxianping commented 7 years ago

hi, @zaphoyd , When I use TSL, I have some problems. Please help analyze, thank you!

[2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [fail] WebSocket Connection 192.168.0.100:8443 - "" /websocket/ganqixian 0 websocketpp.transport.asio:3 Underlying Transport Error [2017-03-28 10:17:53] [error] handle_connect error: Underlying Transport Error [2017-03-28 10:17:53] [connect] Successful connection [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [error] handle_connect error: Underlying Transport Error [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [error] handle_transport_init received error: invalid state [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled)

goodxianping commented 7 years ago

i use demo command line, it works fine. but when i Integrate the code into my project, encountered the above error. this problem has been bothering me for a few days.

In addition, I see the server has received the client connection.

goodxianping commented 7 years ago

It's really weird. When I complie both client_no_tls.hpp and client_tls.hpp, lead to the above error. I comment the client_no_tls code, wss works fine.

goodxianping commented 7 years ago

typedef websocketpp::client<websocketpp::config::asio_tls_client> wsclient_tls; typedef websocketpp::client<websocketpp::config::asio_client> wsclient; note: At the same time to define the above code, NOTLS woks fine, TLS woks failed.

[2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [fail] WebSocket Connection 192.168.0.100:8443 - "" /websocket/ganqixian 0 websocketpp.transport.asio:3 Underlying Transport Error [2017-03-28 10:17:53] [error] handle_connect error: Underlying Transport Error [2017-03-28 10:17:53] [connect] Successful connection [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [error] handle_connect error: Underlying Transport Error [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled) [2017-03-28 10:17:53] [error] handle_transport_init received error: invalid state [2017-03-28 10:17:53] [info] asio handle_timer error: system:125 (Operation Canceled)

goodxianping commented 7 years ago

how to support both ws and wss client?

goodxianping commented 7 years ago

i have fixed this issue by added the code:

websocketpp-0.7.0/websocketpp/transport/asio/connection.hpp:352

` void handle_timer(timer_ptr, timer_handler callback, lib::asio::error_code const & ec) { if(this-get_raw_socket().is_open()) return ;

       if (ec) {
           if (ec == lib::asio::error::operation_aborted) {
               callback(make_error_code(transport::error::operation_aborted));
           } else {
               log_err(log::elevel::info,"asio handle_timer",ec);
               callback(make_error_code(error::pass_through));
           }
       } else {
           callback(lib::error_code());
       }
    }`
stefanofiorentino commented 6 years ago

this row doesn't make sense

if(this-get_raw_socket().is_open())

could you kindly edit the message with right code?

goodxianping commented 6 years ago

sorry, i dont know how to edit messae with right way if(this-get_raw_socket().is_open()) ----> if(this->get_raw_socket().is_open())