# New request while a previous one is processing

**URL:** <https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225>\
**Category:** General\
**Created:** [29 December 2020 17:57 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225 "2020-12-29T17:57:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![drauber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drauber/32/34421_2.png) [@drauber](https://discourse.nodered.org/u/drauber)\
**Post date:** [29 December 2020 17:57 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/1 "2020-12-29T17:57:41Z")

</div>

I set up a flow that receives a token via telegram to make a GET on an API, which keeps looping until a certain condition is true and responds to the telegram with the result received.  
The problem is that if there is more than one call, the previous loop is replaced by the new one.  
Is this normal behavior or am I doing something wrong?  
If this is normal behavior, there can never be a bot with many simultaneous users.

Thanks a lot

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 December 2020 21:12 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/2 "2020-12-29T21:12:02Z")

</div>

It is going to depend on how you've coded it. You will need to share more if you need more specific help.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [29 December 2020 21:14 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/3 "2020-12-29T21:14:55Z")

</div>

> [@drauber](#):
>
> Is this normal behavior

Is what normal behaviour? Receiving more than one call, or the problem with the flow when that happens? As Dave said, if it is the flow that is the problem then you need to adjust the flow to cope with the case when there is more than one call.

---

<div class="post-metadata">

**Author:** ![drauber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drauber/32/34421_2.png) [@drauber](https://discourse.nodered.org/u/drauber)\
**Post date:** [30 December 2020 10:43 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/4 "2020-12-30T10:43:46Z")

</div>

Hello!  
Thanks for the responses.  
I have this

 ![SimpleFlow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/6006125a3ab3a885c47991f5db271de1981b1c1f.png)  
When i send message received by Receiver BotTestCBbot, this start one http request to check status on my http service.  
While the status is QUEUE, delayed new request in 30' and retry, until the status is not equal QUEUE, then reply to the chatId has started the chat: "PROCESSED".  
If **only one** person talk with the bot, works like a charm.  
But, if a second one start chat, the first never receive a response, and the second receive his response.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 December 2020 11:30 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/5 "2020-12-30T11:30:20Z")

</div>

What are you doing in those Function nodes? Are you storing state in context? If so, you need to make sure you key it to the individual request somehow, so each request is handled separately.

---

<div class="post-metadata">

**Author:** ![drauber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drauber/32/34421_2.png) [@drauber](https://discourse.nodered.org/u/drauber)\
**Post date:** [30 December 2020 11:59 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/6 "2020-12-30T11:59:19Z")

</div>

I believe it is just that ... But I don't know how to fix it ☹

In the first function i do this:

```auto
flow.set('chatId', msg.payload.chatId);
flow.set('type', msg.payload.type);
flow.set('txt', msg.payload.content);

msg.lote = msg.payload.content;

return msg;

```

And, in the second, this:

```auto
msg.payload.chatId = flow.get('chatId');
msg.payload.type = flow.get('type');
msg.payload.content = 'Done!'
return msg;

```

And my http request make get on [http://localhost:3333/status/{{{lote}](http://localhost:3333/status/%7B%7B%7Blote%7D)}}

Thank you.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 December 2020 12:29 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/7 "2020-12-30T12:29:31Z")

</div>

rather than use context - you could just move them to other properties on the msg - eg msg.chatId = msg.payload.chatId - and then the reverse later - so they will stay with the msg passing through.

---

<div class="post-metadata">

**Author:** ![drauber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drauber/32/34421_2.png) [@drauber](https://discourse.nodered.org/u/drauber)\
**Post date:** [30 December 2020 13:01 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/8 "2020-12-30T13:01:48Z")

</div>

But in this case http get wil not discard the input msg and generate new one in output?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 December 2020 13:37 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/9 "2020-12-30T13:37:44Z")

</div>

It shouldn’t. It will replace the payload but leave other properties alone hence why I suggested moving them out of payload.

---

<div class="post-metadata">

**Author:** ![drauber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drauber/32/34421_2.png) [@drauber](https://discourse.nodered.org/u/drauber)\
**Post date:** [30 December 2020 14:58 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/10 "2020-12-30T14:58:26Z")

</div>

Very nice! Now it works with more users.  
Thank you very much!

---

<div class="post-metadata">

**Author:** ![drauber](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drauber/32/34421_2.png) [@drauber](https://discourse.nodered.org/u/drauber)\
**Post date:** [30 December 2020 15:02 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/11 "2020-12-30T15:02:08Z")

</div>

This is the flow! If anyone need this..

```auto
[{"id":"4aba3d89.d3ee14","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"cb1150d0.527ba","type":"telegram receiver","z":"4aba3d89.d3ee14","name":"Receiver BotName","bot":"7bb9463f.4d4ab8","saveDataDir":"","filterCommands":false,"x":120,"y":167,"wires":[["f69a002f.1736d","5b1181c2.9921b"],[]]},{"id":"f69a002f.1736d","type":"debug","z":"4aba3d89.d3ee14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":350,"y":87,"wires":[]},{"id":"5b1181c2.9921b","type":"function","z":"4aba3d89.d3ee14","name":"","func":"msg.chatId = msg.payload.chatId;\nmsg.type = msg.payload.type;\nmsg.content = msg.payload.content;\nmsg.lote = msg.payload.content;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":140,"wires":[["68c2b7bd.2b02c8"]]},{"id":"68c2b7bd.2b02c8","type":"http request","z":"4aba3d89.d3ee14","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.0.105:3333/status/{{{lote}}}","tls":"","persist":false,"proxy":"","authType":"","x":570,"y":120,"wires":[["c964f84c.1e3008"]]},{"id":"c964f84c.1e3008","type":"switch","z":"4aba3d89.d3ee14","name":"CheckStatus","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"QUEUE","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":550,"y":380,"wires":[["d6fa7d35.901d2","b3790f1b.5761b"],["b3790f1b.5761b","3e5b5ec.d322ba2"]]},{"id":"b3790f1b.5761b","type":"debug","z":"4aba3d89.d3ee14","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":147,"wires":[]},{"id":"63ed5c3.625b7a4","type":"telegram sender","z":"4aba3d89.d3ee14","name":"Sender BotName","bot":"7bb9463f.4d4ab8","haserroroutput":false,"outputs":1,"x":1070,"y":307,"wires":[[]]},{"id":"d6fa7d35.901d2","type":"delay","z":"4aba3d89.d3ee14","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":700,"y":227,"wires":[["68c2b7bd.2b02c8"]]},{"id":"3e5b5ec.d322ba2","type":"function","z":"4aba3d89.d3ee14","name":"","func":"msg.payload.chatId = msg.chatId;\nmsg.payload.type = msg.type;\nmsg.payload.content = 'Done! ' + msg.lote \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":327,"wires":[["63ed5c3.625b7a4"]]},{"id":"7bb9463f.4d4ab8","type":"telegram bot","botname":"YourBotName","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 January 2021 15:02 UTC](https://discourse.nodered.org/t/new-request-while-a-previous-one-is-processing/38225/12 "2021-01-13T15:02:08Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
