crypto-chassis / ccapi

A header-only C++ library for interacting with crypto exchanges. Bindings for Python, Java, C#, Go, and Javascript are provided.
https://discord.gg/b5EKcp9s8T
MIT License
580 stars 200 forks source link

Reconnect after disconnection #453

Closed djdjoko closed 8 months ago

djdjoko commented 10 months ago

I am testing the reconnect feature after the internet has dropped using market_data_simple_subscription example by switching my wifi connection off. In ccapi_service, the void onFail function should be triggered but that never happens. When I switch on the Wifi, the data is not received anymore, nor is it trying to reconnect. Any suggestions how to fix this?

Thanks

go-dockly commented 9 months ago

I observed the same behavior. Question is does such a case really happen running in a data center? One could also handle socket states with systemd running on debian..

cryptochassis commented 9 months ago

As far as I know, tcp, http, and websocket levels don't have mechanisms to "trigger" something when a disconnect happens. For websocket, we can test whether a connection is broken or not by using ping/pong. You can change the ping/pong intervals here: https://github.com/crypto-chassis/ccapi/blob/develop/include/ccapi_cpp/ccapi_session_options.h.