Closed Arnique closed 3 years ago
When a file is in another DC the library will try to connect to that DC to download it and then disconnects after it's done. this would not remove any update handlers tho.
Are you sure they are being removed ?
That is my assumption since updates stop working after I invoke any API method(after app is already connected and running).
This is what is logged when it switches DCs
[2021-10-13T09:55:38.204Z] [INFO] - [Phone migrated to 5]
[2021-10-13T09:55:38.447Z] [INFO] - [Reconnecting to new data center 5]
[2021-10-13T09:55:38.969Z] [INFO] - [Disconnecting from 149.154.167.91:80/TCPFull...]
[2021-10-13T09:55:38.970Z] [INFO] - [Connecting to 91.108.56.114:80/TCPFull...]
[2021-10-13T09:55:38.971Z] [INFO] - [connection closed]
[2021-10-13T09:55:40.328Z] [INFO] - [Connection to 91.108.56.114:80/TCPFull complete!]
I was hoping I could listen to disconnect or even connect events and reset my app then.
That is my assumption since updates stop working after I invoke any API method(after app is already connected and running).
This is what is logged when it switches DCs
[2021-10-13T09:55:38.204Z] [INFO] - [Phone migrated to 5] [2021-10-13T09:55:38.447Z] [INFO] - [Reconnecting to new data center 5] [2021-10-13T09:55:38.969Z] [INFO] - [Disconnecting from 149.154.167.91:80/TCPFull...] [2021-10-13T09:55:38.970Z] [INFO] - [Connecting to 91.108.56.114:80/TCPFull...] [2021-10-13T09:55:38.971Z] [INFO] - [connection closed] [2021-10-13T09:55:40.328Z] [INFO] - [Connection to 91.108.56.114:80/TCPFull complete!]
I was hoping I could listen to disconnect or even connect events and reset my app then.
This should only happen the first time you login. can you show your code?
Thanks. It's a lot of code and I'm not permitted to share it so I'll just show the calls. So if or example I want to manually login this is what would happen.
await this.client.connect();
[INFO] - [Connecting to 149.154.167.91:80/TCPFull...]
[INFO] - [Connection to 149.154.167.91:80/TCPFull complete!]
await this.client.sendCode(...)
[INFO] - [Phone migrated to 5]
[INFO] - [Reconnecting to new data center 5]
INFO] - [Disconnecting from 149.154.167.91:80/TCPFull...]
[INFO] - [Connecting to 91.108.56.114:80/TCPFull...]
[INFO] - [connection closed]
[INFO] - [Connection to 91.108.56.114:80/TCPFull complete!]
await this.client.invoke(new Api.auth.SignIn({....}))
[ERROR] - [Unhandled error while receiving data]
[ERROR] - [Error: Could not find a matching Constructor ID for the TLObject that was supposed to be
read with ID 571849917. Most likely, a TLObject was trying to be read when
it should not be read. Remaining bytes: 52]
So basically the first method I call after connection causes DC to switch and subsequent calls fail.
Usually using the .start() method is better since it handles all that logic itself.
To start receiving updates you need to call client.getMe() at least once (client;start() does this for you)
Alright thanks. Went with start()
Sometimes my app will disconnect and switch DC while it's running and my update handlers will be removed.
Is there where to handle or listen to these 2 events?