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

How to close socket connection in kline callback function?

Open vanyahuk opened this issue 5 years ago • 1 comments

https://github.com/jaggedsoft/php-binance-api#get-latest-candlestick-data-only

How i can close websocket connection in callback function?

vanyahuk avatar Aug 22 '20 19:08 vanyahuk

Hello, Starting from your given example, you can do the following:

$api->kline(["BTCUSDT", "EOSBTC"], "5m", function($api, $symbol, $chart) {
    // ... do whatever you want

    $endpoint = strtolower($symbol) . '@kline_' . $interval; // See https://github.com/jaggedsoft/php-binance-api/blob/22c7b8d9814e548ca5cefaba0562e76c4d087a8e/php-binance-api.php#L2101

    $api->terminate($endpoint); // This will close the connection
});

dFayet avatar Sep 06 '20 16:09 dFayet