# \[bug-11240\]sendRequestAsync

**URL:** <https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754>\
**Category:** Ignition\
**Created:** [April 18, 2018, 10:38am UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754 "2018-04-18T10:38:07Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [April 18, 2018, 10:38am UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/1 "2018-04-18T10:38:07Z")

</div>

I noticed that the behavior of sendRequestAsync blocks the UI and the callback fires twice.  
Is this expected?

`system.util.sendRequestAsync(project='p', messageHandler='mh', payload={'Id':1}, onSuccess=callback)`

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 18, 2018, 12:28pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/2 "2018-04-18T12:28:46Z")

</div>

Is it possible your callback is what’s blocking? The callback is invoked on the UI thread.

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [April 18, 2018, 3:41pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/3 "2018-04-18T15:41:36Z")

</div>

Possibly, but why does it get invoked twice?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 18, 2018, 3:42pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/4 "2018-04-18T15:42:58Z")

</div>

Don’t know, maybe a bug? It’s certainly not intentional. Does it happen if you create a new script and callback? Have you added logging to see if sendRequestAsync is being called twice or just the callback?

---

<div class="post-metadata">

**Author:** ![cmisztur2](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmisztur2/32/4243_2.png) [@cmisztur2](https://forum.inductiveautomation.com/u/cmisztur2)\
**Post date:** [April 20, 2018, 5:37am UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/5 "2018-04-20T05:37:26Z")

</div>

sendRequestAsync is called once  
onSuccess callback is called twice

Without defining onSuccess, the UI is blocked on sendRequestAsync call.

---

<div class="post-metadata">

**Author:** ![Claus\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Claus\_Nielsen](https://forum.inductiveautomation.com/u/Claus_Nielsen)\
**Post date:** [September 27, 2018, 6:08am UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/6 "2018-09-27T06:08:47Z")

</div>

With ignition 7.9.9 this still seems to be unsolved.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 27, 2018, 3:25pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/7 "2018-09-27T15:25:26Z")

</div>

While there is a bug here (onSuccess added as a kwarg gets fired twice) I wasn’t able to reproduce the blocking behavior.  
To fix the double callbacks, just append the callback separately, ie:

```auto
future = system.util.sendRequestAsync("Test", "echo", {'message': 'message'})
future.onSuccess(handler)

```

rather than:

```auto
future = system.util.sendRequestAsync("Test", "echo", {'message': 'message'}, onSuccess=handler)

```

---

<div class="post-metadata">

**Author:** ![Claus\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@Claus\_Nielsen](https://forum.inductiveautomation.com/u/Claus_Nielsen)\
**Post date:** [September 27, 2018, 6:09pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/8 "2018-09-27T18:09:18Z")

</div>

Haven’t seen the block behavior either, was referring to the double call of the success handler.

Also, noticed that assigning an error handler using kwargs doesn’t work, the error handler is never fired, however using the onError method to assign it, causes it to fire twice aswell.

---

<div class="post-metadata">

**Author:** ![fourmajor](https://avatars.discourse-cdn.com/v4/letter/f/898d66/32.png) [@fourmajor](https://forum.inductiveautomation.com/u/fourmajor)\
**Post date:** [January 24, 2019, 7:51pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/9 "2019-01-24T19:51:28Z")

</div>

I am experiencing the same thing. onError handler not firing when assigned as an argument. When assigning the handler via a method it fires twice.

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [August 17, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/10 "2019-08-17T15:51:22Z")

</div>

I’m still experiencing the the same behavior when setting the callback in this manner `handle.onSuccess(onSuccesFunc)`

My request handler in the gateway is returning a python dictionary with 3 entries, the values being byte arrays. The client onSuccess function is extracting those bytes from the response and writing them to files. My callback is getting triggered 1-3 times.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 19, 2019, 3:09pm UTC](https://forum.inductiveautomation.com/t/bug-11240-sendrequestasync/17754/11 "2019-08-19T15:09:49Z")

</div>

Yes, I filed the ticket at the time but the issue hasn’t been prioritized because the workaround is pretty easy to implement.
