[asyncio.exceptions.TimeoutError] within rasa shell and custom action

Rasa version: 2.6.0

Rasa SDK version: 2.6.0

Python version: 3.8.8

Operating system: linux (ubuntu 18.04)

Hi community,

I am stucked with a very often asyncio time out error when running rasa shell with custom actions using graphQL API:

gql.transport.aiohttp  - >>> {"query": "mutation domain_validation($id_domain: String!) {\n  postDomain(domainId: $id_domain)\n}\n", "variables": {"id_domain": "DM129"}}
Exception occurred while handling uri: 'http://localhost:5055/webhook'
Traceback (most recent call last):
  File "/home/matthieu/anaconda3/envs/rasa-os-2.6/lib/python3.8/site-packages/sanic/app.py", line 938, in handle_request
    response = await response
  File "/home/matthieu/anaconda3/envs/rasa-os-2.6/lib/python3.8/site-packages/rasa_sdk/endpoint.py", line 104, in webhook
    result = await executor.run(action_call)
  File "/home/matthieu/anaconda3/envs/rasa-os-2.6/lib/python3.8/site-packages/rasa_sdk/executor.py", line 397, in run
    events = await utils.call_potential_coroutine(
  File "/home/matthieu/anaconda3/envs/rasa-os-2.6/lib/python3.8/site-packages/rasa_sdk/utils.py", line 230, in call_potential_coroutine
    return await coroutine_or_return_value
  File "/home/matthieu/RASA/rasa/actions/actions.py", line 207, in run
    bool_domain = await set_domain(client, id_domain_selected)
  File "/home/matthieu/RASA/rasa/actions/tiny.py", line 244, in set_domain
    return await session.execute(mutation, variable_values=params)
  File "/home/matthieu/anaconda3/envs/rasa-os-2.6/lib/python3.8/site-packages/gql/client.py", line 408, in execute
    result = await self._execute(document, *args, **kwargs)
  File "/home/matthieu/anaconda3/envs/rasa-os-2.6/lib/python3.8/site-packages/gql/client.py", line 396, in _execute
    return await asyncio.wait_for(
  File "/home/matthieu/anaconda3/envs/rasa-os-2.6/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
    raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError

I tried to increase the DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS from 10 to 60 (seconds) ass suggested in other similar topics but this didn’t solve the problem.

Please find below the associated code in actions.py: class ActionAskFeedbackLoopPrecontent(Action): def name(self): return “action_ask_feedback_loop_precontent”

async def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
    
    ## Set domain selected
    id_domain_selected = tracker.get_slot("id_domain")
    bool_domain = await set_domain(client, id_domain_selected)
    
    ## Get precontent
    if bool_domain:
        precontent_msg = await get_pre_content(client)
        text = precontent_msg.get('tcText').get('reading')
        buttons = [
                {"payload": "/affirm", "title": precontent_msg.get('tcText').get('responses')[0]}
        ]        

        dispatcher.utter_message(text=text, buttons=buttons)
        return []
    else:
        sys.exit("The validation of the selected domain has failed")

Thanks in advance for your lights !

Hi @mattvan83

I face this when there is a latency issue in connecting to the tracker store.

If your tracker store is in different server, check for any network slowness or if that server is too busy.

Same applies to action server as well

Hi @siriusraja

Thanks for your feedback. Actually all is on my local computer and I encounter this problem when running locally rasa shell.

@mattvan83

How much time does your action server takes to get response from graphQL api. Please check if your DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS is greater than the time it takes for your action server to complete the request.

@siriusraja

I increased DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS from the default 10s value up to 60s, however bot still had timeout within the same custom action even though the time laps before timeout lasted less than 60s.