Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Data Streams expiring after 24H #23

Open
mohammad-rj opened this issue Jun 17, 2021 · 16 comments
Open

User Data Streams expiring after 24H #23

mohammad-rj opened this issue Jun 17, 2021 · 16 comments

Comments

@mohammad-rj
Copy link
Contributor

after 24 hours our private subscription expires and does not receive the account and order update

@zhouaini528
Copy link
Owner

For User Data Streams, I have not set up a reconnection mechanism, only public data is reconnected. Because I am worried that it is not triggered by the initiative, there will be a risk of losing private data. Your business end can set up a monitoring application to determine whether the User Data Streams is disconnected. Simply disconnect and re-subscribe. Let me think about whether we need to improve this one.

@mohammad-rj
Copy link
Contributor Author

mohammad-rj commented Jun 17, 2021

what is the best way?
i must delete or unsubscribe the last private subscribe
and subscribe again? Or is there a better way?
can we add this mechanism on main code ?

@zhouaini528
Copy link
Owner

What version of binance-php do you currently have? Is it 2.1.1?

@mohammad-rj
Copy link
Contributor Author

I'm up to the latest commit

@zhouaini528
Copy link
Owner

You look at your log if there is this information
"private connection close,ready to reconnect"

Are you subscribing to spot, future, or delivery?

@mohammad-rj
Copy link
Contributor Author

mohammad-rj commented Jun 17, 2021

usdt-future
where i must looking for this log ?
"private connection close,ready to reconnect"

private function reconnection($global,$type='public',array $keysecret=[]){
$all_sub=$global->get('all_sub');
if(empty($all_sub)) return;

    if($type=='public'){
        $temp=[];
        foreach ($all_sub as $v){
            if(!is_array($v)) $temp[]=$v;
        }

        $global->save('add_sub',$temp);
    }else{

    }
}

and what is this function ?

can we have a function for reconnection private channel ?

@zhouaini528
Copy link
Owner

zhouaini528 commented Jun 17, 2021

You gave too little information. You need to check the log. I can't locate the problem. But in this case, your business end only needs to re-subscribe once.

This log is in the location set by your config, and the location in the code is at 'private connection close,ready to reconnect'

    private function reconnection($global,$type='public',array $keysecret=[]){
        $all_sub=$global->get('all_sub');
        if(empty($all_sub)) return;

        if($type=='public'){
            $temp=[];
            foreach ($all_sub as $v){
                if(!is_array($v)) $temp[]=$v;
            }

            $global->save('add_sub',$temp);
        }else{

        }
    }

This code indicates that when the user disconnects, they need to re-subscribe to the data. I haven't perfected it here, I only completed the public data. Next I have to complete the right place

I will finish reconnecting to the private channel as soon as possible

@mohammad-rj
Copy link
Contributor Author

mohammad-rj commented Jun 17, 2021

this must was in
usdt-future-server2021-06-16-2021-06-17.txt
log of server_usdt_future.php , right ?
but there is no "private connection close,ready to reconnect"

also
when i check test function, that u define for test and debug with switch number 99 on client_usdt_future.php
it say :
[secret] => xxx my secret
[connection] => 1
[listen_key] => xxx my listen_key
[listen_key_time] => 1623918598
[connection_close] => 0

connection is true and connection_close is false
also it just past 42 minutes of this [listen_key_time] => 1623918598 (its fresh)

i think the reconnecting work truly, but after 24 h binance does not recognize as valid !

I think the previous key should be deleted and a new key created, every 24 hours
based on what is described in the Bainance document "A single connection to fstream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark"
https://binance-docs.github.io/apidocs/futures/en/#user-data-streams

what do you think ? did I get it right?

@zhouaini528
Copy link
Owner

Your findings are very useful, I need time to test, after the test is successful, I will @you

@zhouaini528
Copy link
Owner

Hello, I didn't find 24-hour disconnection after the test. Look at my screenshot, running time is 2021-06-17, I changed the account order, executed and got the data.
微信截图_20210621134116

微信截图_20210621134203

I'm using spot. I'll try futures.

@mohammad-rj
Copy link
Contributor Author

I have seen this problem several times on futures

@zhouaini528
Copy link
Owner

I am testing futures, please wait for my test results

@zhouaini528
Copy link
Owner

After 26 hours of testing, I found no disconnection. I changed my account balance and successfully received the data. I will now extend the test time on this basis.

微信截图_20210622164416

微信截图_20210622163823

@mohammad-rj
Copy link
Contributor Author

oh, so why this issue happened for me ? is it possible it happened because of queue

@zhouaini528
Copy link
Owner

zhouaini528 commented Jun 22, 2021

The queue data saves 100 pieces of data by default, you can set it by configuring queue_count=100. Because I only do a small amount of data test, I will try to add a lot of data later. please wait for my test results

$binance->config([
    //Number of messages WS queue shuold hold, default 100
    'queue_count'=>100,
]);

@zhouaini528
Copy link
Owner

After 6 days 20 hours of testing, I found no disconnection.

微信截图_20210628110242

微信截图_20210628110441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants