# asyncio.TimeoutError

**URL:** <https://forum.rasa.com/t/asyncio-timeouterror/28043>\
**Category:** Rasa Open Source\
**Created:** [April 25, 2020, 5:38pm UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043 "2020-04-25T17:38:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandharv30](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@gandharv30](https://forum.rasa.com/u/gandharv30)\
**Post date:** [April 25, 2020, 5:38pm UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/1 "2020-04-25T17:38:32Z")

</div>

I am trying to fetch a value from a database through an API. I am able to do so successfully and print those in the terminal through actions.py, but the bot is not able to show those values and it raises an error asyncio.TimeoutError Traceback (most recent call last): File “/Users/gandharv/opt/anaconda3/lib/python3.7/site-packages/rasa/core/run.py”, line 134, in run\_cmdline\_io sender\_id=conversation\_id, File “/Users/gandharv/opt/anaconda3/lib/python3.7/site-packages/rasa/core/channels/console.py”, line 139, in record\_messages async for response in bot\_responses: File “/Users/gandharv/opt/anaconda3/lib/python3.7/site-packages/rasa/core/channels/console.py”, line 105, in send\_message\_receive\_stream async for line in resp.content: File “/Users/gandharv/opt/anaconda3/lib/python3.7/site-packages/aiohttp/streams.py”, line 39, in **anext** rv = await self.read\_func() File “/Users/gandharv/opt/anaconda3/lib/python3.7/site-packages/aiohttp/streams.py”, line 328, in readline await self.\_wait(‘readline’) File “/Users/gandharv/opt/anaconda3/lib/python3.7/site-packages/aiohttp/streams.py”, line 296, in \_wait await waiter File “/Users/gandharv/opt/anaconda3/lib/python3.7/site-packages/aiohttp/helpers.py”, line 596, in **exit** raise asyncio.TimeoutError from None concurrent.futures.\_base.TimeoutError Transport closed @ (‘127.0.0.1’, 60445) and exception experienced during error handling

Here is my actions.py file

from typing import Any, Text, Dict, List from rasa\_sdk import Action, Tracker from rasa\_sdk.executor import CollectingDispatcher from email.message import EmailMessage from rasa\_core\_sdk.events import SlotSet import smtplib import psycopg2

class ActionHelloWorld(Action):

```
def name(self) -> Text:
    return "action_hello_world"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

```

# Getting slot values

```
    sender_email = tracker.get_slot('email')
    entity_name = tracker.get_slot('entity_name')

```

# DatabaseConncetion

```
    user = "my user"
    password = "mypass"
    host = " "
    port = 8081
    database = "dla"
    
    db_conn = psycopg2.connect(host=host, user=user, password=password, database=database)
    cursor = db_conn.cursor()
    sql_query = "SELECT * FROM operational_metadata WHERE bor_name = %s; "
    cursor.execute(sql_query, (entity_name,))
    result = cursor.fetchall()
    for row in result:
        a0 = row[0]
        a1 = row[1]
        a2 = row[2]
        a3 = row[3]
        a4 = row[4]
        a5 = row[5]
        a6 = row[6]
        a7 = row[7]
        a8 = row[8]
        a9 = row[9]
        a10 = row[10]
        a11 = row[11]
        a12 = row[12]
        a13 = row[13]
        a14 = row[14]
        a15 = row[15]
        a16 = row[16]
    response = """ details are: {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}.""".format(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16)
    print(response)
    dispatcher.utter_message(response)

```

# SendingEmail

```
    msg = EmailMessage()
    msg.set_content(response)
    msg['Subject'] = 'Final Testing'
    msg['From'] = "myemail"
    msg['To'] = sender_email
    server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
    server.login("myemail", "mypass")
    server.send_message(msg)
    server.quit()
    return [SlotSet('email',sender_email),SlotSet('entity_name',entity_name)]

```

I am using Rasa 1.9.5 and rasa shell command along with rasa run actions to run the action server

---

<div class="post-metadata">

**Author:** ![bparikh99](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/bparikh99/32/8327_2.png) [@bparikh99](https://forum.rasa.com/u/bparikh99)\
**Post date:** [April 26, 2020, 5:15am UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/2 "2020-04-26T05:15:05Z")

</div>

Hey @gandharv30 that happens refer this [Multiple sequential actions cause asyncio TimeoutError · Issue #4381 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/issues/4381) and when I’m integrating with it telegram, giving me all responses with out any asyncio error

---

<div class="post-metadata">

**Author:** ![gandharv30](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@gandharv30](https://forum.rasa.com/u/gandharv30)\
**Post date:** [April 26, 2020, 10:27am UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/3 "2020-04-26T10:27:54Z")

</div>

Thanks @bparikh99, I did refer to this. But it did not help me much. My code does not takes 10 sec to execute as I its evident from terminal. Could you help me solve this issue? Also @Juste

---

<div class="post-metadata">

**Author:** ![bparikh99](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/bparikh99/32/8327_2.png) [@bparikh99](https://forum.rasa.com/u/bparikh99)\
**Post date:** [April 26, 2020, 11:48am UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/4 "2020-04-26T11:48:34Z")

</div>

@gandharv30 updating rasa could solve your proble, i think so!!

---

<div class="post-metadata">

**Author:** ![gandharv30](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@gandharv30](https://forum.rasa.com/u/gandharv30)\
**Post date:** [April 26, 2020, 2:49pm UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/5 "2020-04-26T14:49:14Z")

</div>

I am using the latest version @bparikh99

---

<div class="post-metadata">

**Author:** ![alijboor](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/alijboor/32/13839_2.png) [@alijboor](https://forum.rasa.com/u/alijboor)\
**Post date:** [April 6, 2021, 9:52am UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/6 "2021-04-06T09:52:58Z")

</div>

hi dear i was face alot of these errors now lets debug where is the error. first before the

> db\_conn

type **try:**

and after

> dispatcher.utter\_message(response)

type

except mysql.connector.Error as error:

```
        print("parameterized query failed {}".format(error))

        dispatcher.utter_message("error messages here")

```

just make the right format for the code then in the terminal you will get the error where exactly.

2nd method to trace it in each line by line type some deferent print to terminal to see witch of these is work and where the error occurs .

hope that help you.

---

<div class="post-metadata">

**Author:** ![andrejankas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andrejankas/32/16812_2.png) [@andrejankas](https://forum.rasa.com/u/andrejankas)\
**Post date:** [September 29, 2021, 1:13pm UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/7 "2021-09-29T13:13:06Z")

</div>

I am facing the same issue, did you solve it?

---

<div class="post-metadata">

**Author:** ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)\
**Post date:** [September 29, 2021, 1:25pm UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/8 "2021-09-29T13:25:06Z")

</div>

@andrejankas What is your current issue or error, can you even share the rasa --version and error screenshot?

---

<div class="post-metadata">

**Author:** ![andrejankas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/andrejankas/32/16812_2.png) [@andrejankas](https://forum.rasa.com/u/andrejankas)\
**Post date:** [September 29, 2021, 2:04pm UTC](https://forum.rasa.com/t/asyncio-timeouterror/28043/9 "2021-09-29T14:04:42Z")

</div>

#### Versions

```shell
Rasa Version : 2.8.7
Minimum Compatible Version: 2.8.0
Rasa SDK Version : 2.8.1
Rasa X Version : None
Python Version : 3.7.9
Operating System : Windows-10-10.0.19041-SP0

```

### Error

```shell
2021-09-29 10:33:59 ERROR asyncio - Task exception was never retrieved
future: <Task finished coro=<configure_app.<locals>.run_cmdline_io() done, defined at c:\users\anka\virtualenvs\rasa\lib\site-packages\rasa\core\run.py:131> exception=TimeoutError()>
Traceback (most recent call last):
  File "c:\users\anka\virtualenvs\rasa\lib\site-packages\rasa\core\run.py", line 137, in run_cmdline_io
    sender_id=conversation_id,
  File "c:\users\anka\virtualenvs\rasa\lib\site-packages\rasa\core\channels\console.py", line 182, in record_messages
    async for response in bot_responses:
  File "c:\users\anka\virtualenvs\rasa\lib\site-packages\rasa\core\channels\console.py", line 137, in _send_message_receive_stream
    async for line in resp.content:
  File "c:\users\anka\virtualenvs\rasa\lib\site-packages\aiohttp\streams.py", line 39, in __anext__
    rv = await self.read_func()
  File "c:\users\anka\virtualenvs\rasa\lib\site-packages\aiohttp\streams.py", line 338, in readline
    await self._wait("readline")
  File "c:\users\anka\virtualenvs\rasa\lib\site-packages\aiohttp\streams.py", line 306, in _wait
    await waiter
  File "c:\users\anka\virtualenvs\rasa\lib\site-packages\aiohttp\helpers.py", line 656, in __exit__
    raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
Transport closed @ ('127.0.0.1', 51941) and exception experienced during error handling

```

### Function for sending mail

```python
    def send_email(to_email: Text, content: Text, subject: Text):
        msg = EmailMessage()
        msg['Subject'] = subject
        msg['From'] = EmailSender.EMAIL_ADDRESS
        msg['To'] = to_email
        msg.set_content(content)
        with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
            smtp.login(EmailSender.EMAIL_ADDRESS, EmailSender.EMAIL_PASSWORD)
            smtp.send_message(msg)

```

_Note: Same as OP, my code doesn’t takes 10 sec to execute._

@nik202
