php-binance-api icon indicating copy to clipboard operation
php-binance-api copied to clipboard

kline function, reconnect when socket close.

Open mishari88 opened this issue 5 years ago • 1 comments

Hi,

I needed some help here. I am using kline function to get the data coming from binance server with around 140 symbols pairs. As the data are flowing in, there are chances where there will be error in the websocket causing it to close due to network errors. How do i change the code to make it to reconnect and continue to receive data for that particular symbol?

The code in question here is. public function kline( ... $ws->on('close', function ($code = null, $reason = null) use ($callback2, $symbol, $loop, $interval) { echo "kline({$symbol},{$interval}) WebSocket Connection closed! ({$code} - {$reason})" . PHP_EOL; $loop->stop(); call_user_func($callback2, $this, $symbol, $interval);

Does the $loop->stop, stops that particular symbol or stops all websocket?

Can you give me some pointers where I should start looking to write the reconnect code ?

Thank you mishari.

mishari88 avatar Apr 11 '19 07:04 mishari88

@mishari88 Did you fix the problem?

CrazyBoy49z avatar Feb 17 '21 22:02 CrazyBoy49z