# Handle asyncio.exceptions.CancelledError in custom connector

**URL:** <https://forum.rasa.com/t/handle-asyncio-exceptions-cancellederror-in-custom-connector/52774>\
**Category:** Rasa Open Source\
**Created:** [April 22, 2022, 11:39am UTC](https://forum.rasa.com/t/handle-asyncio-exceptions-cancellederror-in-custom-connector/52774 "2022-04-22T11:39:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![usas](https://avatars.discourse-cdn.com/v4/letter/u/f6c823/32.png) [@usas](https://forum.rasa.com/u/usas)\
**Post date:** [April 22, 2022, 11:39am UTC](https://forum.rasa.com/t/handle-asyncio-exceptions-cancellederror-in-custom-connector/52774/1 "2022-04-22T11:39:37Z")

</div>

Hello, **RASA version: 3.0.8**

I wrote a custom connector. If the response from the actions server takes more than 9 s then `asyncio.exceptions.CancelledError` is raised. Is it possible to extend this time when I `await on_new_message`? Also if the exception is catched and ok is returned from input channel, the rasa does not return response.

Here is the stack trace:

```auto
rasaserver-1 | Traceback (most recent call last):
rasaserver-1 | File "/mybot/addons/my_connector.py", line 222, in handle_output
rasaserver-1 | await on_new_message(user_msg)
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/rasa/core/channels/channel.py", line 89, in handler
rasaserver-1 | await app.agent.handle_message(message)
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/rasa/core/agent.py", line 419, in handle_message
rasaserver-1 | return await self.processor.handle_message(message)
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 148, in handle_message
rasaserver-1 | await self._run_prediction_loop(message.output_channel, tracker)
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 768, in _run_prediction_loop
rasaserver-1 | should_predict_another_action = await self._run_action(
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/rasa/core/processor.py", line 868, in _run_action
rasaserver-1 | events = await action.run(
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/rasa/core/actions/action.py", line 722, in run
rasaserver-1 | response = await self.action_endpoint.request(
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/rasa/utils/endpoints.py", line 165, in request
rasaserver-1 | async with session.request(
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/aiohttp/client.py", line 1117, in __aenter__
rasaserver-1 | self._resp = await self._coro
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/aiohttp/client.py", line 544, in _request
rasaserver-1 | await resp.start(conn)
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 890, in start
rasaserver-1 | message, payload = await self._protocol.read() # type: ignore
rasaserver-1 | File "/opt/venv/lib/python3.8/site-packages/aiohttp/streams.py", line 604, in read
rasaserver-1 | await self._waiter
rasaserver-1 | asyncio.exceptions.CancelledError

```

---

<div class="post-metadata">

**Author:** ![usas](https://avatars.discourse-cdn.com/v4/letter/u/f6c823/32.png) [@usas](https://forum.rasa.com/u/usas)\
**Post date:** [April 22, 2022, 2:52pm UTC](https://forum.rasa.com/t/handle-asyncio-exceptions-cancellederror-in-custom-connector/52774/2 "2022-04-22T14:52:46Z")

</div>

Anyone? 🙏 🙏 🙏

---

<div class="post-metadata">

**Author:** ![usas](https://avatars.discourse-cdn.com/v4/letter/u/f6c823/32.png) [@usas](https://forum.rasa.com/u/usas)\
**Post date:** [April 23, 2022, 9:34am UTC](https://forum.rasa.com/t/handle-asyncio-exceptions-cancellederror-in-custom-connector/52774/3 "2022-04-23T09:34:18Z")

</div>

I know where is the problem. The client has a timeout set. Is it possible to return from webhook handler and run `on_new_message` in new thread.
