# Multiple calls/queries to canister blocks them all from sending back the response

**URL:** <https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406>\
**Category:** Developers\
**Created:** [August 10, 2021, 7:34pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406 "2021-08-10T19:34:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehsan6sha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ehsan6sha/32/2460_2.png) [@ehsan6sha](https://forum.dfinity.org/u/ehsan6sha)\
**Post date:** [August 10, 2021, 7:34pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/1 "2021-08-10T19:34:05Z")

</div>

Hi  
I want to know if this is normal that when multiple calls or queries are sent simultaniousely to a canister, eventhough they are executed, the resonse is never sent as if it is blocked. And after that the canister does not respond(Even executes) any new command. Is there any watchdog capability in place?

---

<div class="post-metadata">

**Author:** ![CarstenJ](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/carstenj/32/2729_2.png) [@CarstenJ](https://forum.dfinity.org/u/CarstenJ)\
**Post date:** [August 11, 2021, 4:05pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/2 "2021-08-11T16:05:03Z")

</div>

Hey @ehsan6sha,

How are you making calls/queries to the canister?

---

<div class="post-metadata">

**Author:** ![ehsan6sha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ehsan6sha/32/2460_2.png) [@ehsan6sha](https://forum.dfinity.org/u/ehsan6sha)\
**Post date:** [August 11, 2021, 5:54pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/3 "2021-08-11T17:54:06Z")

</div>

the same code of CanCan:

```auto
const putChunkPromises: Promise<[] | [null]>[] = [];
for (
    let byteStart = 0;
    byteStart < file.size;
    byteStart += MAX_CHUNK_SIZE, chunk++
  ) {
    putChunkPromises.push(
      processAndUploadChunk(videoBuffer, byteStart, file.size, videoId, chunk)
    );
  }
await Promise.all(putChunkPromises);
//It never reaches here

```

and processAndUploadChunk is basically calling this actor which is from CanCan:

```auto
export async function putVideoChunk(
  videoId: string,
  chunkNum: number,
  chunkData: number[]
) {
  return (await CanCan.actor).putVideoChunk(videoId, chunkNum, chunkData);
}

```

If I just send one request at a time instead of simultanious ones, the front-end receives the response, however, if I do it the above way, although the canister recieves them and processes them(I verified with loggin on canister), no response is ever received from canister, and if I send another command to canister, it dose not process it as if it is busy.

And I tried this in browser too using CanCan and same result, so not sure if there is a seting somewhere for canister to be bale to pool multiple calls?

---

<div class="post-metadata">

**Author:** ![CarstenJ](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/carstenj/32/2729_2.png) [@CarstenJ](https://forum.dfinity.org/u/CarstenJ)\
**Post date:** [August 12, 2021, 6:00pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/4 "2021-08-12T18:00:27Z")

</div>

This is not normal behavior.

Can you provide a description of how we can reproduce this, step-by-step?

Also, have you noticed at how many simultaneously requests the canister starts to become non-responsive?

---

<div class="post-metadata">

**Author:** ![PaulLiu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulliu/32/4701_2.png) [@PaulLiu](https://forum.dfinity.org/u/PaulLiu)\
**Post date:** [August 12, 2021, 7:29pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/5 "2021-08-12T19:29:39Z")

</div>

Is this on local dfx or publicly deployed to the Internet Computer?

If it is local dfx, are you on Linux or Mac or Windows?

---

<div class="post-metadata">

**Author:** ![ehsan6sha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ehsan6sha/32/2460_2.png) [@ehsan6sha](https://forum.dfinity.org/u/ehsan6sha)\
**Post date:** [August 12, 2021, 8:04pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/6 "2021-08-12T20:04:00Z")

</div>

@PaulLiu @CarstenJ

I am trying to replicate a small part of the code that is not working.

here are the other responses:  
1- I am using Ubuntu64  
2- it becomes unresponsive when a batch of first Promises is received and processed and it does not repond to anymore calls(even when called directly from terminal) and does not repond back to front end  
3- I am tsting locally/Linux

---

<div class="post-metadata">

**Author:** ![PaulLiu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulliu/32/4701_2.png) [@PaulLiu](https://forum.dfinity.org/u/PaulLiu)\
**Post date:** [August 12, 2021, 8:10pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/7 "2021-08-12T20:10:37Z")

</div>

> [@ehsan6sha](#):
>
> 3- I am tsting locally/Linux

Thanks for the info. I think it is a bug with the proxy server run by `dfx start` because I ran into it before. The problem doesn’t seem to affect Mac users, or when you deploy your canister to the real network.

I actually had a fix, but the fix was unsatisfying (it made the proxy process single threaded). Let me see if there is any other workaround in the meantime.

---

<div class="post-metadata">

**Author:** ![PaulLiu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulliu/32/4701_2.png) [@PaulLiu](https://forum.dfinity.org/u/PaulLiu)\
**Post date:** [August 12, 2021, 10:05pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/8 "2021-08-12T22:05:30Z")

</div>

Here is a workaround, let me know if it works for you.

1. Start replica by itself.

Just run `dfx replica`. There will then be a file `.dfx/replica-configuration/replica-1.port`. The content of this file is the localhost port that replica listens to.

`dfx replica` command optionally can take a port number as argument, but if there already exists a configuration file `.dfx/state/replicated_state/ic.json5`, it will actually ignore the command line argument.

1. Build a binary of `icx-proxy` from [GitHub - dfinity/agent-rs: A collection of libraries and tools for building software around the Internet C](https://github.com/dfinity/agent-rs/). You may also download a pre-built binary from [Releases · ninegua/agent-rs · GitHub](https://github.com/ninegua/agent-rs/releases).

2. Run `icx-proxy` to connect to the replica.

`icx-proxy --address 0.0.0.0:8080 --replica http://localhost:$(cat .dfx/replica-configuration/replica-1.port)`

This will serve at HTTP port 8080. You should change it to match what your local dfx.json uses.

Then everything else should work the same.

The additional benefit of serving through `icx-proxy` is that you can resolve canisters in the domain name if you setup your DNS correctly. For example I can visit my local canister at `http://qaa6y-5yaaa-aaaaa-aaafa-cai.tower.server:8080/` where tower.server is a local domain I setup through `dnsmasq`.

---

<div class="post-metadata">

**Author:** ![ehsan6sha](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ehsan6sha/32/2460_2.png) [@ehsan6sha](https://forum.dfinity.org/u/ehsan6sha)\
**Post date:** [August 12, 2021, 11:30pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/9 "2021-08-12T23:30:03Z")

</div>

Wow! Thank you it works. just a question, how then do you run front-end ?  
normally it is npm run start, but now that dfx is not started through the normal process it complains

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [August 12, 2021, 11:40pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/10 "2021-08-12T23:40:39Z")

</div>

You can remove the `copy:types` setup from `package.json`, and then `npm start` should stop complaining. You’ll need to manually handle the declarations for now though, and my blog post might be a good reference for that

---

<div class="post-metadata">

**Author:** ![PaulLiu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulliu/32/4701_2.png) [@PaulLiu](https://forum.dfinity.org/u/PaulLiu)\
**Post date:** [August 12, 2021, 11:49pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/11 "2021-08-12T23:49:42Z")

</div>

As for access frontend through a browser, I think icx-proxy only resolves canister through the domain name. This is a bit hard to setup. So it is not for everyone… but if you want to try, you can configure dnsmasq on your host, and point /etc/resolv.conf to this dnsmasq server.

In the dnsmasq configure something like:

```auto
address=/local.server/127.0.0.1

```

This would allow domain names like `<canister-id>.local.server` to resolve to your localhost. Then you can point browser to URL like `http://<canister_id>.local.server:8080`.

You can also configure your LAN to use a custom DNS with the above setting. This is how I test my app on cell phones at home.

I understand this is quite involved, and not for everyone. Hopefully next dfx release will have the bug fix for the hang problem on Linux.

---

<div class="post-metadata">

**Author:** ![PaulLiu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulliu/32/4701_2.png) [@PaulLiu](https://forum.dfinity.org/u/PaulLiu)\
**Post date:** [August 12, 2021, 11:54pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/12 "2021-08-12T23:54:11Z")

</div>

I just noticed that there is a shortcut if you only want to use frontend to visit one specific canister.

There is a `--dns-alias domain.name:canisterId` option to `icx-proxy`. You can try specifying `--dns-alias localhost:<canister_id>`. Then `http://localhost:8080` might just work. I’ve not tried myself yet though.

---

<div class="post-metadata">

**Author:** ![jzxchiang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jzxchiang/32/2592_2.png) [@jzxchiang](https://forum.dfinity.org/u/jzxchiang)\
**Post date:** [August 15, 2021, 6:11pm UTC](https://forum.dfinity.org/t/multiple-calls-queries-to-canister-blocks-them-all-from-sending-back-the-response/6406/13 "2021-08-15T18:11:14Z")

</div>

> [@PaulLiu](#):
>
> cat .dfx/replica-configuration/replica-1.port

Amazing, this worked for me too.

FYI, I hit the same issue on a Mac (not M1). I was trying to pre-populate my canister “database” using a bunch of concurrent updates from a local Node.js script, and hit the same problem as OP. Now it’s solved. But I’m pretty sure other people using `dfx start` will hit this same roadblock very soon, if they haven’t already.
