Rasa X start issue (asyncio / uvloop problem)

When I start my chatbot with rasa shell, it looks fine. When I start with rasa x, I receive the following errors:

2021-06-04 11:07:04 ERROR asyncio - Task was destroyed but it is pending! task: <Task pending name=‘Task-8’ coro=<TCPConnector._resolve_host() running at /home/kormoczi/.local/lib/python3.8/site-packages/aiohttp/connector.py:865> wait_for=<Future finished exception=gaierror(-3, ‘Temporary failure in name resolution’)> cb=[TCPConnector._create_direct_connection..drop_exception() at /home/kormoczi/.local/lib/python3.8/site-packages/aiohttp/connector.py:1002]> 2021-06-04 11:07:04 ERROR asyncio - Unhandled exception in event loop Traceback (most recent call last): File “uvloop/dns.pyx”, line 389, in uvloop.loop.__on_addrinfo_resolved File “uvloop/loop.pyx”, line 894, in uvloop.loop.Loop._getaddrinfo.callback File “uvloop/loop.pyx”, line 1257, in uvloop.loop.Loop.call_soon File “uvloop/loop.pyx”, line 635, in uvloop.loop.Loop._call_soon File “uvloop/loop.pyx”, line 639, in uvloop.loop.Loop._call_soon_handle File “uvloop/loop.pyx”, line 668, in uvloop.loop.Loop._check_closed RuntimeError: Event loop is closed [2021-06-04 11:07:08 +0200] [29039] [INFO] Goin’ Fast @ http://0.0.0.0:5002 2021-06-04 11:07:08 INFO sanic.root - Goin’ Fast @ http://0.0.0.0:5002

After this, the bot work (looks like everything is ok), but I would like to understand this problem, and correct it.

Do you have any suggestion or advice?

Thank you and best regards, Csaba

Hi @kormoczi this looks like a problem with the asyncio loop exiting. Are there any other processes running on your machine that might be using the asyncio loop?

Hi @b-quachtran I am using a fresh Ubuntu install in a VirtualBox VM, only some development tools have been installed (git, meld, mc, Visual Studio Code). And the issue is there even if I start Rasa X immediately after system startup, without running any other apps (I only start a terminal window to launch Rasa X). So I think there is no other processes running that might be using the asyncio loop…

Hmm @kormoczi, which version of Rasa X do you have installed? This could potentially be a bug.

Hi @b-quachtran, I have checked my Rasa X install, and the version is 0.39.3 (Rasa==2.6.2, Rasa SDK==2.6.0). I though, it is a latest version, but as I could check right now, Rasa X at version 0.40.x. (By the way, I have installed it in local mode, approx 3 weeks ago.) I have tried upgrade, and both Rasa and Rasa SDK went up for 2.7.0, but a simple upgrade (python3 -m pip install --upgrade rasa-x) did not change Rasa X version.

But it looks like, that this Rasa/Rasa SDK upgrade solved my problem, the error messages has disappeared. (Also strange, I was almost sure, that the problem is with Rasa X and not with Rasa…)

Sorry not thinking about this earlier, thank you for reminding me for checking the versions!

Hi @b-quachtran,

I have a new install, right now the versions are the followings: rasa==2.7.1 rasa-sdk==2.7.0 rasa-x==0.41.1 And the problem appeares again…

Moreover, I am receiving additional errors after some time:

[2021-07-07 12:58:28 +0200] [2332] [ERROR] Exception occurred while handling uri: ‘http://10.200.131.140:5002/api/projects/d efault/models?limit=1&offset=0&tag=production’ Traceback (most recent call last): File “/usr/local/lib/python3.8/dist-packages/sanic/app.py”, line 938, in handle_request response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 216, in decorated_function return await await_and_return_response(args, kwargs, request) File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 146, in await_and_return_response response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/blueprints/models.py”, line 44, in get_models models, total_models = await _model_service(request).get_models( File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 747, in get_models minimum_compatible_version = await self.minimum_compatible_version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 160, in minimum_compatible_v ersion info = await stack_service.version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/stack_service.py”, line 92, in version response = await session.get( File “/usr/local/lib/python3.8/dist-packages/aiohttp/client.py”, line 619, in _request break File “/usr/local/lib/python3.8/dist-packages/aiohttp/helpers.py”, line 656, in exit raise asyncio.TimeoutError from None asyncio.exceptions.TimeoutError 2021-07-07 12:58:28 ERROR sanic.root - Exception occurred while handling uri: ‘http://10.200.131.140:5002/api/projects/d efault/models?limit=1&offset=0&tag=production’ Traceback (most recent call last): File “/usr/local/lib/python3.8/dist-packages/sanic/app.py”, line 938, in handle_request response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 216, in decorated_function return await await_and_return_response(args, kwargs, request) File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 146, in await_and_return_response response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/blueprints/models.py”, line 44, in get_models models, total_models = await _model_service(request).get_models( File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 747, in get_models minimum_compatible_version = await self.minimum_compatible_version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 160, in minimum_compatible_v ersion info = await stack_service.version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/stack_service.py”, line 92, in version response = await session.get( File “/usr/local/lib/python3.8/dist-packages/aiohttp/client.py”, line 619, in _request break File “/usr/local/lib/python3.8/dist-packages/aiohttp/helpers.py”, line 656, in exit raise asyncio.TimeoutError from None asyncio.exceptions.TimeoutError

[2021-07-07 12:58:29 +0200] [2332] [ERROR] Exception occurred while handling uri: ‘http://10.200.131.140:5002/api/projects/d efault/models?limit=1&offset=0’ Traceback (most recent call last): File “/usr/local/lib/python3.8/dist-packages/sanic/app.py”, line 938, in handle_request response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 216, in decorated_function return await await_and_return_response(args, kwargs, request) File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 146, in await_and_return_response response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/blueprints/models.py”, line 44, in get_models models, total_models = await _model_service(request).get_models( File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 747, in get_models minimum_compatible_version = await self.minimum_compatible_version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 160, in minimum_compatible_v ersion info = await stack_service.version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/stack_service.py”, line 92, in version response = await session.get( File “/usr/local/lib/python3.8/dist-packages/aiohttp/client.py”, line 619, in _request break File “/usr/local/lib/python3.8/dist-packages/aiohttp/helpers.py”, line 656, in exit raise asyncio.TimeoutError from None asyncio.exceptions.TimeoutError 2021-07-07 12:58:29 ERROR sanic.root - Exception occurred while handling uri: ‘http://10.200.131.140:5002/api/projects/d efault/models?limit=1&offset=0’ Traceback (most recent call last): File “/usr/local/lib/python3.8/dist-packages/sanic/app.py”, line 938, in handle_request response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 216, in decorated_function return await await_and_return_response(args, kwargs, request) File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py”, line 146, in await_and_return_response response = await response File “/usr/local/lib/python3.8/dist-packages/rasax/community/api/blueprints/models.py”, line 44, in get_models models, total_models = await _model_service(request).get_models( File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 747, in get_models minimum_compatible_version = await self.minimum_compatible_version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py”, line 160, in minimum_compatible_v ersion info = await stack_service.version() File “/usr/local/lib/python3.8/dist-packages/rasax/community/services/stack_service.py”, line 92, in version response = await session.get( File “/usr/local/lib/python3.8/dist-packages/aiohttp/client.py”, line 619, in _request break File “/usr/local/lib/python3.8/dist-packages/aiohttp/helpers.py”, line 656, in exit raise asyncio.TimeoutError from None asyncio.exceptions.TimeoutError

Any idea or suggestions?

Thank you!

Any further ideas? I get very similar issue on my RASA X deployment:

rasa-x_1           | Traceback (most recent call last):                                                                                                                   
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/sanic/app.py", line 973, in handle_request                                                            
rasa-x_1           |     response = await response                                                                                                                        
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py", line 216, in decorated_function                                   
rasa-x_1           |     return await await_and_return_response(args, kwargs, request)                                                                                    
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/rasax/community/api/decorators.py", line 146, in await_and_return_response                            
rasa-x_1           |     response = await response                                                                                                                        
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/rasax/community/api/blueprints/models.py", line 44, in get_models                                     
rasa-x_1           |     models, total_models = await _model_service(request).get_models(                                                                                 
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py", line 747, in get_models                                   
rasa-x_1           |     minimum_compatible_version = await self.minimum_compatible_version()                                                                             
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/rasax/community/services/model_service.py", line 160, in minimum_compatible_version                   
rasa-x_1           |     info = await stack_service.version()                                                                                                             
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/rasax/community/services/stack_service.py", line 92, in version                                       
rasa-x_1           |     response = await session.get(                                                                                                                    
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/aiohttp/client.py", line 504, in _request                                                             
rasa-x_1           |     await resp.start(conn)                                                                                                                           
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/aiohttp/client_reqrep.py", line 860, in start                                                         
rasa-x_1           |     self._continue = None                                                                                                                            
rasa-x_1           |   File "/usr/local/lib/python3.8/dist-packages/aiohttp/helpers.py", line 596, in __exit__
rasa-x_1           |     raise asyncio.TimeoutError from None
rasa-x_1           | asyncio.exceptions.TimeoutError

After that the models looks like their reloading causing bot to freeze for couple of minutes.

@kormoczi

  1. Go to the directory: venv/Lib/site-packages/rasa/core/channels/console.py
  2. Change the default value of DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS to more than 10, what ever time you required.

Hope it will fix your issue.

Well… I’m actually using RASA X deployment, so I don’t really have possibility to change rasa source code (all is managed with dockers), so… That’s not really a way to go here.

@BarMin My bad I not noticed that you using docker. I mixed with kormoczi. @BarMin Can I asked which Image you using for Rasa-X? Try use low version or latest. @BarMin Or try install sanic using requirement.txt from docker. Hope it will solve.

@kormoczi as per your actual error on this post Rasa X start issue (asyncio / uvloop problem) the solution which I find for my use-case(encountered this error recently) just in your default browser please clear your cookies and cache whilst closing the rasa x server and run it again it will not show you this error again. Thanks.

@nik202, thank you for your suggestion, and I need to check later, but as I remember, this problem came up for me when I started rasa x on the server, no browser running at that time (yet), so don’t think this suggestion applies to my case, unfortunately.

@nik202, I just realized right now, that I haven’t tested your other suggestion, somehow I missed that reply, sorry (“DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS”), I will try out. Thanks!

@kormoczi No worries, please if you having any error please do share me the screenshot of that error. Good Luck!