Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket Channel not working in rasa 3.0.0 #10412

Closed
3 tasks
hsm207 opened this issue Nov 28, 2021 · 28 comments · Fixed by #10862
Closed
3 tasks

Socket Channel not working in rasa 3.0.0 #10412

hsm207 opened this issue Nov 28, 2021 · 28 comments · Fixed by #10862
Assignees
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework effort:atom-squad/2 Label which is used by the Rasa Atom squad to do internal estimation of task sizes. type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@hsm207
Copy link
Contributor

hsm207 commented Nov 28, 2021

Rasa Open Source version

3.0.0

Rasa SDK version

3.0.0

Rasa X version

No response

Python version

3.8

What operating system are you using?

Linux

What happened?

Using the rasa chat widget to talk to the bot throws the following exception in rasa 3.0.0:

[2021-11-28 13:09:58 +0000] [4700] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/socket.io/?EIO=4&transport=polling&t=Nrcgg60'
Traceback (most recent call last):
  File "handle_request", line 83, in handle_request
    class Sanic(BaseSanic, metaclass=TouchUpMeta):
  File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_server.py", line 317, in handle_request
    return await self._make_response(r, environ)
  File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_server.py", line 385, in _make_response
    response = make_response(
  File "/opt/venv/lib/python3.8/site-packages/engineio/async_drivers/sanic.py", line 102, in make_response
    return HTTPResponse(body=payload, content_type=content_type,
TypeError: 'NoneType' object is not callable

This did not happen in rasa 2.8.15.

This repo contains a reproducible example.

Command / Request

No response

Relevant log output

No response

Definition of done

  • Determine if the cause is in Rasa Open Source 3.0
  • If the problem is in Rasa Chat Widget, update this issue and move to Fabric backlog
  • Try to add test for this?
@hsm207 hsm207 added type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. area:rasa-oss 🎡 Anything related to the open source Rasa framework labels Nov 28, 2021
@b-quachtran
Copy link
Contributor

It looks like Rasa 3.0 is using python-socketio version 5.5.0: https://github.com/RasaHQ/rasa/blob/main/poetry.lock#L2129. We'll need to check if the corresponding Javascript version used in the Rasa chat widget is compatible (https://github.com/miguelgrinberg/python-socketio)

@b-quachtran
Copy link
Contributor

@gausie Do you know what socket-io version that Rasa webchat widget is currently using?

@nimitkh
Copy link

nimitkh commented Dec 2, 2021

I have experimented this on rasa/webchat/ and it's working fine on rasa 3.0 [MacOS] with:

pip install sanic==21.6.0
pip install Sanic-Cors==1.0.0
pip install sanic-routing==0.7.0

@jonra1993
Copy link

jonra1993 commented Dec 3, 2021

I am facing similar error with rasa 3.0.1 I just added https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.js on my index.html

[2021-12-02 20:35:12 -0500] [88145] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/socket.io/?EIO=4&transport=polling&t=NrzxbjF'
Traceback (most recent call last):
  File "handle_request", line 83, in handle_request
    class Sanic(BaseSanic, metaclass=TouchUpMeta):
  File "/Users/jona/Library/Caches/pypoetry/virtualenvs/rasa-assistant-_8IB3lkj-py3.7/lib/python3.7/site-packages/engineio/asyncio_server.py", line 317, in handle_request
    return await self._make_response(r, environ)
  File "/Users/jona/Library/Caches/pypoetry/virtualenvs/rasa-assistant-_8IB3lkj-py3.7/lib/python3.7/site-packages/engineio/asyncio_server.py", line 388, in _make_response
    response_dict['response'], environ)
  File "/Users/jona/Library/Caches/pypoetry/virtualenvs/rasa-assistant-_8IB3lkj-py3.7/lib/python3.7/site-packages/engineio/async_drivers/sanic.py", line 103, in make_response
    status=int(status.split()[0]), headers=headers_dict)
TypeError: 'NoneType' object is not callable

I tried installing @nimitkh version using poetry but I got a version error with sanic==21.6.0 and sanic-routing==0.7.0

image

@TyDunn TyDunn added the effort:atom-squad/2 Label which is used by the Rasa Atom squad to do internal estimation of task sizes. label Dec 3, 2021
@qathom
Copy link

qathom commented Dec 8, 2021

I am also facing similar error with Rasa v3.0.1.
I made sure to follow the socketio compatibility table:
Rasa v3 is using: python-socketio 5.x and I tested my frontend client with JavaScript Socket.IO 4.4.0.
Dependency version fix from #10412 (comment) is working..

@alwx
Copy link
Contributor

alwx commented Dec 10, 2021

This issue happens because of this: miguelgrinberg/python-engineio#251

@alwx
Copy link
Contributor

alwx commented Dec 14, 2021

I made some investigation and here are the results:
Unfortunately, we have to wait for python-engineio to get fixed (miguelgrinberg/python-engineio#251) because we made a bunch of changes to how we use sanic, and downgrading it to 21.6.0 makes little sense because in this case we would need to revert our changes, and that can potentially lead to issues with rasa-sdk as well.

We can speed things up a bit by fixing this issue: miguelgrinberg/python-engineio#251

@nimitkh
Copy link

nimitkh commented Dec 15, 2021

[update] on version rasa==3.0.2 and rasa-sdk==3.0.2 with the following versions, it working with rasa/webchat. [MacOS]


python-engineio==4.3.0
python-socketio==5.5.0
rasa==3.0.2
rasa-sdk==3.0.2
sanic==21.6.0
Sanic-Cors==1.0.0
sanic-routing==0.7.0
sanic-jwt==1.7.0
sanic-plugin-toolkit==1.2.0
Sanic-Plugins-Framework==0.9.5
socketIO-client==0.7.2

@Italosayan
Copy link

@nimitkh which python version are you using?

@nimitkh
Copy link

nimitkh commented Dec 18, 2021

@Italosayan It is 3.7.7

@alwx alwx removed their assignment Dec 28, 2021
@m-vdb
Copy link
Collaborator

m-vdb commented Jan 10, 2022

It's now fixed in the python-engineio repo, I've just asked for a pypi release

@m-vdb
Copy link
Collaborator

m-vdb commented Jan 11, 2022

python-engineio has released a new version with the fix: 4.3.1 🎉

@carlad
Copy link
Contributor

carlad commented Jan 24, 2022

@amn41 may have discovered a different issue with python-engineio 4.3.1 and sanic 21.9.3

I’m having an issue with sanic websockets and Rasa Web Chat and suspect it’s related to this. I’m running the latest docker image rasa/rasa:3.0.5 which has the following installed:

$ pip list | grep anic
sanic                   21.9.3
Sanic-Cors              1.0.1
sanic-jwt               1.7.0
sanic-plugin-toolkit    1.2.1
sanic-routing           0.7.2

If I hook up Rasa Web Chat to this server, I get an exception when trying to start a chat:

rasa-production_1  | 2022-01-20 10:34:08 DEBUG    rasa.core.channels.socketio  - User JRwVm-eqBQ_Hkr90AAAB connected to socketIO endpoint.
rasa-production_1  | Exception occurred while handling uri: 'ws://docker-stack/socket.io/?EIO=4&transport=websocket&sid=z75hbjVaYkWkQmbdAAAA'
rasa-production_1  | Traceback (most recent call last):
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/sanic/server/protocols/websocket_protocol.py", line 119, in websocket_handshake
rasa-production_1  |     subprotocols = list(subprotocols)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 261, in inner
rasa-production_1  |     return func(*args, **kwds)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 685, in __getitem__
rasa-production_1  |     params = tuple(_type_check(p, msg) for p in params)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 685, in <genexpr>
rasa-production_1  |     params = tuple(_type_check(p, msg) for p in params)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 149, in _type_check
rasa-production_1  |     raise TypeError(f"{msg} Got {arg!r:.100}.")
rasa-production_1  | TypeError: Parameters to generic types must be types. Got 0.
rasa-production_1  | 
rasa-production_1  | During handling of the above exception, another exception occurred:
rasa-production_1  | 
rasa-production_1  | Traceback (most recent call last):
rasa-production_1  |   File "handle_request", line 83, in handle_request
rasa-production_1  |     class Sanic(BaseSanic, metaclass=TouchUpMeta):
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_server.py", line 271, in handle_request
rasa-production_1  |     packets = await socket.handle_get_request(environ)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_socket.py", line 89, in handle_get_request
rasa-production_1  |     return await getattr(self, '_upgrade_' + transport)(environ)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_socket.py", line 142, in _upgrade_websocket
rasa-production_1  |     return await ws(environ)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/async_drivers/sanic.py", line 122, in __call__
rasa-production_1  |     self._sock = await protocol.websocket_handshake(request)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/sanic/server/protocols/websocket_protocol.py", line 132, in websocket_handshake
rasa-production_1  |     raise ServerError(msg, status_code=500)
rasa-production_1  | sanic.exceptions.ServerError: Failed to open a WebSocket connection.

Using sanic 21.6.0 and python-engineio 4.3.1 works.

@Adheesh1107
Copy link

Adheesh1107 commented Jan 25, 2022

I am facing an exception while trying to start a conversation with the bot using rasa-webchat.
Versions :
rasa : 3.0.5
sanic : 21.6.0
sanic-routing : 0.7.0
python-engineio : 4.3.1

Exception:

2022-01-25 17:30:13 DEBUG    rasa.core.channels.socketio  - User FDlqpflyb3RoLF_OAAAD connected to socketIO endpoint.
2022-01-25 17:30:13 DEBUG    rasa.core.channels.socketio  - User FDlqpflyb3RoLF_OAAAD connected to socketIO endpoint.
2022-01-25 17:30:35 DEBUG    rasa.core.channels.socketio  - User FDlqpflyb3RoLF_OAAAD disconnected from socketIO endpoint.
[2022-01-25 17:30:35 +0530] [4614] [ERROR] Exception occurred while handling uri: 'ws://localhost:5005/socket.io/?EIO=4&transport=websocket&sid=Rqt75Tlbo11YI4ZzAAAC'
Traceback (most recent call last):
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/app.py", line 783, in handle_request
    f"Invalid response type {response!r} "
sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)
[2022-01-25 17:30:35 +0530] [4614] [ERROR] Exception occurred while handling uri: 'ws://localhost:5005/socket.io/?EIO=4&transport=websocket&sid=Rqt75Tlbo11YI4ZzAAAC'
Traceback (most recent call last):
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/app.py", line 783, in handle_request
    f"Invalid response type {response!r} "
sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/http.py", line 129, in http1
    await self.protocol.request_handler(self.request)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic_plugin_toolkit/realm.py", line 566, in _handle_request_21_03
    raise cancelled
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic_plugin_toolkit/realm.py", line 554, in _handle_request_21_03
    _ = await real_handle(request)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/app.py", line 791, in handle_request
    await self.handle_exception(request, e)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/app.py", line 704, in handle_exception
    await response.send(end_stream=True)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/response.py", line 122, in send
    await self.stream.send(data, end_stream=end_stream)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/http.py", line 335, in http1_response_header
    await self._send(ret)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_3.x_env/lib/python3.7/site-packages/sanic/server.py", line 268, in send
    raise CancelledError
concurrent.futures._base.CancelledError

Few things to note:

  • the bot is functional through socket communication and it works as expected.
  • The above exception occurs only when we reload the page and click the chat widget.

@ChatbotTest22
Copy link

ChatbotTest22 commented Feb 1, 2022

Hi,
Were you able to resolve the above issue?
Facing similar error.

[ERROR] Exception occurred while handling uri: 'ws://localhost:5005/socket.io/?EIO=4&transport=websocket&sid=-YcweomlAWd89WMIAAAA'
Traceback (most recent call last):
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\site-packages\sanic\server\protocols\websocket_protocol.py", line 119, in websocket_handshake
subprotocols = list(subprotocols)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\typing.py", line 254, in inner
return func(*args, **kwds)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\typing.py", line 634, in getitem
params = tuple(_type_check(p, msg) for p in params)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\typing.py", line 634, in
params = tuple(_type_check(p, msg) for p in params)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\typing.py", line 142, in _type_check
raise TypeError(f"{msg} Got {arg!r:.100}.")
TypeError: Parameters to generic types must be types. Got 0.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "handle_request", line 83, in handle_request
class Sanic(BaseSanic, metaclass=TouchUpMeta):
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\site-packages\engineio\asyncio_server.py", line 271, in handle_request
packets = await socket.handle_get_request(environ)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\site-packages\engineio\asyncio_socket.py", line 89, in handle_get_request
return await getattr(self, 'upgrade' + transport)(environ)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\site-packages\engineio\asyncio_socket.py", line 142, in _upgrade_websocket
return await ws(environ)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\site-packages\engineio\async_drivers\sanic.py", line 122, in call
self._sock = await protocol.websocket_handshake(request)
File "c:\users\chatbotanaconda3\envs\chatwidget\lib\site-packages\sanic\server\protocols\websocket_protocol.py", line 132, in websocket_handshake
raise ServerError(msg, status_code=500)
sanic.exceptions.ServerError: Failed to open a WebSocket connection.

@donodje donodje mentioned this issue Feb 11, 2022
4 tasks
@donodje donodje linked a pull request Feb 11, 2022 that will close this issue
4 tasks
@m-vdb
Copy link
Collaborator

m-vdb commented Feb 14, 2022

@donodje can we close this issue?

@m-vdb m-vdb closed this as completed Feb 21, 2022
@thisisishara
Copy link
Contributor

@amn41 may have discovered a different issue with python-engineio 4.3.1 and sanic 21.9.3

I’m having an issue with sanic websockets and Rasa Web Chat and suspect it’s related to this. I’m running the latest docker image rasa/rasa:3.0.5 which has the following installed:

$ pip list | grep anic
sanic                   21.9.3
Sanic-Cors              1.0.1
sanic-jwt               1.7.0
sanic-plugin-toolkit    1.2.1
sanic-routing           0.7.2

If I hook up Rasa Web Chat to this server, I get an exception when trying to start a chat:

rasa-production_1  | 2022-01-20 10:34:08 DEBUG    rasa.core.channels.socketio  - User JRwVm-eqBQ_Hkr90AAAB connected to socketIO endpoint.
rasa-production_1  | Exception occurred while handling uri: 'ws://docker-stack/socket.io/?EIO=4&transport=websocket&sid=z75hbjVaYkWkQmbdAAAA'
rasa-production_1  | Traceback (most recent call last):
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/sanic/server/protocols/websocket_protocol.py", line 119, in websocket_handshake
rasa-production_1  |     subprotocols = list(subprotocols)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 261, in inner
rasa-production_1  |     return func(*args, **kwds)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 685, in __getitem__
rasa-production_1  |     params = tuple(_type_check(p, msg) for p in params)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 685, in <genexpr>
rasa-production_1  |     params = tuple(_type_check(p, msg) for p in params)
rasa-production_1  |   File "/usr/lib/python3.8/typing.py", line 149, in _type_check
rasa-production_1  |     raise TypeError(f"{msg} Got {arg!r:.100}.")
rasa-production_1  | TypeError: Parameters to generic types must be types. Got 0.
rasa-production_1  | 
rasa-production_1  | During handling of the above exception, another exception occurred:
rasa-production_1  | 
rasa-production_1  | Traceback (most recent call last):
rasa-production_1  |   File "handle_request", line 83, in handle_request
rasa-production_1  |     class Sanic(BaseSanic, metaclass=TouchUpMeta):
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_server.py", line 271, in handle_request
rasa-production_1  |     packets = await socket.handle_get_request(environ)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_socket.py", line 89, in handle_get_request
rasa-production_1  |     return await getattr(self, '_upgrade_' + transport)(environ)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/asyncio_socket.py", line 142, in _upgrade_websocket
rasa-production_1  |     return await ws(environ)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/engineio/async_drivers/sanic.py", line 122, in __call__
rasa-production_1  |     self._sock = await protocol.websocket_handshake(request)
rasa-production_1  |   File "/opt/venv/lib/python3.8/site-packages/sanic/server/protocols/websocket_protocol.py", line 132, in websocket_handshake
rasa-production_1  |     raise ServerError(msg, status_code=500)
rasa-production_1  | sanic.exceptions.ServerError: Failed to open a WebSocket connection.

Using sanic 21.6.0 and python-engineio 4.3.1 works.

Facing the same issue with rasa 3.0.8 (sanic==21.9.3)

@m-vdb
Copy link
Collaborator

m-vdb commented Mar 3, 2022

This fix is not released yet and will be released in 3.1

@Adheesh1107
Copy link

I'm facing an issue in webchat even when I tried with unreleased rasa having the fix for this issue.
I took the code from RasaHQ's main branch (which has this current issue addressed) and installed the dependencies pertaining to unreleased rasa using poetry as described by the docs.
When I tried to run it with rasa webchat, the old socket exception didn't occur. But when we close the session, it's throwing an exception.

Versions:

Rasa Version : 3.0.8
Minimum Compatible Version : 3.0.0
Rasa SDK Version : 3.0.5
Python Version :  3.7.4

Exception:

2022-03-03 20:44:48 DEBUG    rasa.core.channels.socketio  - User PuIQ5ep8xl8Xx_5WAAAd disconnected from socketIO endpoint.
[2022-03-03 20:44:48 +0530] [13248] [ERROR] Exception occurred while handling uri: 'ws://localhost:5005/socket.io/?EIO=4&transport=websocket&sid=JKutAeQkewNitK-zAAAc'
Traceback (most recent call last):
  File "handle_request", line 125, in handle_request
    class Sanic(BaseSanic, metaclass=TouchUpMeta):
sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)

Also, I am facing an error when I killed the rasa core using ctrl + c. Basically, if we stop the server, the following error message is displayed in the terminal. If there were 'n' sessions active when stopping the core server, the same error message repeats 'n' times

Error:

2022-03-03 20:44:49 ERROR    asyncio  - Task was destroyed but it is pending!
source_traceback: Object created at (most recent call last):
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/bin/rasa", line 5, in <module>
    main()
  File "/Users/adheesh.arumugam/rasa/rasa/__main__.py", line 119, in main
    cmdline_arguments.func(cmdline_arguments)
  File "/Users/adheesh.arumugam/rasa/rasa/cli/run.py", line 95, in run
    rasa.run(**vars(args))
  File "/Users/adheesh.arumugam/rasa/rasa/api.py", line 61, in run
    **kwargs,
  File "/Users/adheesh.arumugam/rasa/rasa/core/run.py", line 230, in serve_application
    workers=number_of_workers,
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/sanic/app.py", line 1204, in run
    serve_single(server_settings)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/sanic/server/runners.py", line 206, in serve_single
    serve(**server_settings)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/sanic/server/runners.py", line 155, in serve
    loop.run_forever()
  File "connection_task", line 15, in connection_task
    from sanic.http import Http, Stage
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/sanic/http.py", line 146, in http1
    await self.protocol.request_handler(self.request)
  File "handle_request", line 83, in handle_request
    )
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/engineio/asyncio_server.py", line 259, in handle_request
    jsonp_index)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/engineio/asyncio_server.py", line 396, in _handle_connect
    self.start_background_task(self._service_task)
  File "/Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/engineio/asyncio_server.py", line 332, in start_background_task
    return asyncio.ensure_future(target(*args, **kwargs))
task: <Task pending coro=<AsyncServer._service_task() running at /Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/engineio/asyncio_server.py:498> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x1633f1590>()] created at /Users/adheesh.arumugam/.pyenv/versions/3.7.4/lib/python3.7/asyncio/tasks.py:590> created at /Users/adheesh.arumugam/.virtualenvs/rasa_test_env/lib/python3.7/site-packages/engineio/asyncio_server.py:332>

Both of the errors didn't occur in the older version of rasa and rasa-sdk.

@rgstephens
Copy link
Contributor

If you look at the PR it was merged into 3.0.x branch, not main. I built from 3.0.x and it fixed the socket issue.

@Adheesh1107
Copy link

@rgstephens I replicated the same process by switching to the 3.0.x branch and performing poetry install. The above-mentioned error and exception still persist.
The error occurs when we stop the core server and an exception occurs when we close the browser window/tab

@rgstephens
Copy link
Contributor

You can try the docker image I built - stephens/rasa:3.0.8-full-10412. I've had this deployed for a couple of weeks and am using sockets with the botfront rasa chat widget.

@ghost
Copy link

ghost commented Jul 29, 2022

The socket issue still persists even with the latest Rasa version (3.2.4). I'm using rasa-webchat as the chat interface. The issue can be reproduced by:

  1. Closing the chat session (by closing the browser tab).
  2. Navigating to a different page and coming back to the page with the chatbot.

Screenshot 2022-07-29 at 12 09 52 PM

Version Reference:

Python packages: (Python: 3.8.4)
rasa==3.2.4
rasa-sdk==3.2.0
sanic==21.12.1
Sanic-Cors==2.0.1
sanic-jwt==1.8.0
sanic-routing==0.7.2
python-engineio==4.3.3
python-socketio==5.7.1

JavaScript dependencies: (Node: 12.16.1)
socket.io-client@4.5.1

@ltfschoen
Copy link

Using sanic 21.6.0 and python-engineio 4.3.1 works.

to try and overcome the http://<IP_ADDRESS>:5005/socket.io/?EIO=3&transport=polling&t=123 error that when trying to connect from my local machine using a chatbot front-end that uses socket.io such as https://github.com/botfront/rasa-webchat to the Rasa server that i was hosting on an AWS EC2 instance , i tried the following:

  • tried using the latest Rasa 3.x but that didn't work, and reverting back to Rasa v2.2.10 but that didn't work too
  • tried reverting back to Rasa 3.0.0 as suggested in this thread but that didn't work
    • opened TCP port 5005 for IPv4 and IPv6 incoming traffic
    • note that when i tried to use the dependencies mentioned in this thread by @nimitkh i got the following error:
# sanic-plugins-framework 0.9.5 requires sanic<21,>=18.12.0, but you have sanic 21.6.0 which is incompatible.
# rasa 3.0.2 requires sanic-routing<0.8.0,>=0.7.2, but you have sanic-routing 0.7.0 which is incompatible.
  where i was using Ubuntu 22.04 with Python 3.7.7, so i used `--no-deps` as follows to make sure a version of sanic less than 21.9 was installed:
python -m pip install rasa==3.0.0
python -m pip install python-engineio==4.3.1
python -m pip install python-socketio==5.5.0
python -m pip install rasa-sdk==3.0.0
python -m pip install Sanic-Cors==1.0.0
python -m pip install sanic-jwt==1.7.0
python -m pip install sanic-plugin-toolkit==1.2.0
python -m pip install socketIO-client==0.7.2
python -m pip install --no-deps Sanic-Plugins-Framework==0.9.5
python -m pip install --no-deps sanic-routing==0.7.0
python -m pip install --no-deps sanic==21.6.0

so i forked this restful chatbot interface so i don't need to use socket.io https://github.com/ltfschoen/Chatbot-Widget and that worked

@rgstephens
Copy link
Contributor

@ltfschoen I have several bots working with the botfront widget and 3.x here. They're all on various 3.x releases.

@ltfschoen
Copy link

@ltfschoen I have several bots working with the botfront widget and 3.x here. They're all on various 3.x releases.

i figured out what i was doing wrong.
like you say https://github.com/botfront/rasa-webchat does work fine with Rasa 3.x.

first thing i hadn't done was in credentials.yml i had session_persistence: true/false instead of just session_persistence: true, but that wasn't the issue.

i updated the index.html file so it had socketUrl: "http://<MY_EC2_PUBLIC_IP>:5005"
when i ran the web server i still got error GET http://<MY_EC2_PUBLIC_IP>:5005/socket.io/?EIO=3&transport=polling&t=OIt2MeS 400 (Bad Request)

but when i create EC2 Security > Inbound rule to allow port forwarding on 5000 and 5005 on TCP 0.0.0.0/0 it still didn't work, but then i noticed in the terminal window of the Rasa server where i'd run python -m rasa run --enable-api --cors "*", it had an error shown: Rasa server is up and running. The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO).

so given that i knew that EIO was an abbreviation for the EngineIO version since i recently answered this stackoverflow question https://stackoverflow.com/questions/74265891/what-is-eio-3transport-pollingt-in-socket-io/74508268#74508268, i quicky checked that the Rasa server was running

python -m pip show python-engineio  -> 4.3.1
python -m pip show python-socketio  -> 5.5.0

but the error was telling me that the client was using an unsupported version, which was EngineIO v3, since the query string parameters from the client were EIO=3, so i needed it to show EIO=4 instead...

in index.html i was using <script src="https://cdn.jsdelivr.net/npm/rasa-webchat@1.5.0/lib/index.min.js" type="text/javascript"></script>, but when i changed @1.5.0 to @1.0.0 or removed the version number so it became <script src="https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.min.js" type="text/javascript"></script> it gave me an error saying WebChat.default.init is undefined, so i simply changed that code to WebChat.default instead of WebChat.default.init, since the latest version doesn't use .init. See https://github.com/botfront/rasa-webchat/blob/master/dev/src/index.html#L8, and when i did that and restarted the Flask server and refreshed the webpage at http://<MY_EC2_PUBLIC_IP>:5000 it finally worked

@totalhack
Copy link

I see something similar with Rasa 3.4.0 from the official docker image (rasa/rasa:3.4.0-full) and recent versions of FF and Chrome using the web widget Rasa recommends in the docs, but it appears to only happen on refresh. Start a chat, works fine, hit refresh, get this error server side:

rasa-rasa-1  | Exception occurred while handling uri: 'ws://127.0.0.1:5005/socket.io/?EIO=4&transport=websocket&sid=GCuxT_yUCL6z0xZYAAAG'
rasa-rasa-1  | Traceback (most recent call last):
rasa-rasa-1  |   File "handle_request", line 124, in handle_request
rasa-rasa-1  | sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)

Note that I do not get the The client is using an unsupported version of the Socket.IO or Engine.IO protocols message some other people saw for similar errors in forum threads I researched.

My credentials.yml settings for socketio are as follows:

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

Again, the initial chat works fine, this happens when refreshing the page. Perhaps it's a new/different bug?

I've seen some people recommend Botfront but that project appears to be dead.

@Sats2812
Copy link

I see something similar with Rasa 3.4.0 from the official docker image (rasa/rasa:3.4.0-full) and recent versions of FF and Chrome using the web widget Rasa recommends in the docs, but it appears to only happen on refresh. Start a chat, works fine, hit refresh, get this error server side:

rasa-rasa-1  | Exception occurred while handling uri: 'ws://127.0.0.1:5005/socket.io/?EIO=4&transport=websocket&sid=GCuxT_yUCL6z0xZYAAAG'
rasa-rasa-1  | Traceback (most recent call last):
rasa-rasa-1  |   File "handle_request", line 124, in handle_request
rasa-rasa-1  | sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)

Note that I do not get the The client is using an unsupported version of the Socket.IO or Engine.IO protocols message some other people saw for similar errors in forum threads I researched.

My credentials.yml settings for socketio are as follows:

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

Again, the initial chat works fine, this happens when refreshing the page. Perhaps it's a new/different bug?

I've seen some people recommend Botfront but that project appears to be dead.

Hey, did you find a solution for this ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework effort:atom-squad/2 Label which is used by the Rasa Atom squad to do internal estimation of task sizes. type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet