Dfinity/agent-js error, terminated

Hello,
When pinging an ICP main net canister from client side using dfinity/agent-js, at specific time intervals to fetch updated data, it responds correctly for the first few calls, but then starts throwing errors :

  Expected to find result for path subnet, but instead found nothing.
  AgentReadStateError: Caught exception while attempting to read state: terminated

and

[cause]: SocketError: other side closed
          at TLSSocket.onSocketEnd (node:internal/deps/undici/undici:8994:26)
          at TLSSocket.emit (node:events:531:35)
          at endReadableNT (node:internal/streams/readable:1696:12)
          at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
        code: 'UND_ERR_SOCKET'

What’s the issue behind this? Also, what’s the best way to ping canisters for updated data from client side?

1 Like

Hey @h1teshtr1path1

This might be an issue with the HTTP gateway (former boundary node). Can you share a bit more information with us:

  • How often do you fetch the data?
  • Are you always making read state calls?
  • After how many calls does it fail? Is it consistent after every X calls?
1 Like

Hello @rbirkner,

  1. I call canisters often say every 5-6 sec.
  2. No, there are update calls as well in between queries.
  3. I can’t comment on this, as far as I observed logs it’s not consistent. Also, sometimes it gets resolved and resumed just like before and starts calling canisters again, other times it stays blocked for 6-8hrs and keep getting this error.

Hey @h1teshtr1path1

Being blocked for several hours is super odd. The HTTP gateways have some measures in place to block misbehaving clients, but that would lead to a ban of a few minutes and requires sending thousands of requests per second.

Is it possible for you to log the IP address of the HTTP gateway you are connecting to?