gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

gramjs doesn't handle network unreliability well

Open KishanBagaria opened this issue 2 years ago • 3 comments

We've been testing out gramjs for a while with the following client params:

{
  retryDelay: 1_000,
  autoReconnect: true,
  connectionRetries: Infinity,
  useWSS: true,
}

When the network is changed and/or after extended sleep-wake of the device, these two errors happen frequently:

  1. Cannot send requests while disconnected. You need to call .connect()
  2. Disconnect (caused from $methodName)

According to the client params, neither of the issues should happen and it should retry/reconnect indefinitely. I can confirm these are not happening when the device is offline since the error logging endpoints work. Also seen this reported earlier without resolution: https://github.com/gram-js/gramjs/issues/303 https://github.com/gram-js/gramjs/issues/372 https://github.com/gram-js/gramjs/issues/338

KishanBagaria avatar Aug 05 '22 17:08 KishanBagaria

are you able to reproduce them easily? I know about this issue it's just very hard to reproduce so trying to solve it is even harder.

There were some fixes to some cases where it happened but it's not fully gone yet.

So if someone knows some easy steps to reproduce it so I can try and figure out a solution that would be great.

painor avatar Aug 05 '22 19:08 painor

It should be easy to repro in theory but the feedback loop will be slow. A possible repro should be to keep a gramjs script running at all times which invokes new Api.updates.GetDifference etc. and other methods to fetch data on a loop. Then when the network changes / sleep-wakes occur, the connection will break and not recover. Again this is slow, but I'll post here if I find more info on this.

KishanBagaria avatar Aug 05 '22 20:08 KishanBagaria

any updates on this?

i remember i faced another one https://github.com/gram-js/gramjs/issues/344

MoKhajavi75 avatar Sep 16 '22 22:09 MoKhajavi75