dmikushin / binance-cxx-api

Binance Bincoin Exchange C++ API
MIT License
66 stars 42 forks source link

Websocket error: lws_ssl_client_connect1 #19

Open lbandy opened 3 years ago

lbandy commented 3 years ago

Hello,

I compiled everything and can use the REST functions without issues, but I'm struggling to find a solution to getting the websocket examples to work.

Without changing the original code, the connection fails with lws_ssl_client_connect1. If I add LCCSCF_ALLOW_INSECURE, there are no errors, but no data is received.

Any ideas on how can I debug/fix it?

dmikushin commented 3 years ago

Hi @lbandy , the error suggests that secure SSL session could not be established. I won't be surprised that insecure session is not implemented by Binance endpoint at all for obvious reasons. SSL may fail due to general reasons. The first thing to check is that your system clock is synchronized with an NTP server. Secondly, encrypted connections could be disallowed by your company or network provider - check that SSL works for you in general, e.g. GMail web interface.

Satoshi-Yoda commented 3 years ago

Good day!

Seems like I have a simular? issue: REST works fine, but websockets don't. It fails to connect with events like that: Firstly happens this: <binance::Websocket::event_cb> LWS_CALLBACK_GET_THREAD_ID with result tid == 1 Then this: <binance::Websocket::event_cb> LWS_CALLBACK_CLIENT_CONNECTION_ERROR With

N: LWS: 4.1.4-srcinfo-cache, loglevel 7
N: NET CLI SRV H1 H2 WS IPv6-absent
E: SSL error: unable to get local issuer certificate (preverify_ok=0;err=20;depth=1)

After some googling I found something about "my system did not trust server certificate". Hmm... Any ideas?