WTelegramClient not reconnecting after Internet connection is lost

297 views Asked by At

I use WTelegramClient. The client does not reconnect after the Internet connection is restored.

Showing this:

Connecting to 149.154.167.91:443... SocketException HostUnreachable (10065): A socket operation was attempted to an unreachable host. Connecting to [2001:67c:4e8:f004::a]:443... Connecting to 149.154.167.50:443...

1

There are 1 answers

0
Wizou On

After the connection has been established, transient connection losses should be detected and handled automatically by WTelegramClient:

  • A reconnection is attempted automatically after a few seconds and pending API calls are automatically resent.
  • After MaxAutoReconnect reconnection attempts, if the connection can still not be re-established, the client.OnUpdate event receives a ReactorError object, so you can decide what to do.

Now the log you provide doesn't give much context so I presume this happens at the very beginning of opening a session with WTelegramClient.
In this case there is no automatic retry, you should just catch the connection error using a try..catch around the ConnectAsync or LoginUserIfNeeded call, and decide what to do, when to retry the connection.