Rasa 3.x problem using official widget

I am trying to use RASA official chat widget with server running in localhost. These are the steps I performed.

  1. Start action server rasa run actions
  2. Start rasa server rasa run -m models --enable-api --log-file out.log --cors "*"
  3. Create index.html as below.
<html>
  <body>
    <div id="rasa-chat-widget" data-websocket-url="http://localhost:5005"></div>
    <script src="https://unpkg.com/@rasahq/rasa-chat" type="application/javascript"></script>
  </body>
</html>

My credentials.yml looks like this

# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/messaging-and-voice-channels

rest:
#  # you don't need to provide anything here - this channel doesn't
#  # require any credentials


#facebook:
#  verify: "<verify>"
#  secret: "<your secret>"
#  page-access-token: "<your page access token>"

#slack:
#  slack_token: "<your slack token>"
#  slack_channel: "<the slack channel>"
#  slack_signing_secret: "<your slack signing secret>"

socketio:
 user_message_evt: user_uttered
 bot_message_evt: bot_uttered
 session_persistence: true

#mattermost:
#  url: "https://<mattermost instance>/api/v4"
#  token: "<bot token>"
#  webhook_url: "<callback URL>"

# This entry is needed if you are using Rasa X. The entry represents credentials
# for the Rasa X "channel", i.e. Talk to your bot and Share with guest testers.
rasa:
  url: "http://localhost:5002/api"

However when I visit the index.html page, I got error below and there is no response from the bot.

2021-12-10 12:56:33 INFO     root  - Rasa server is up and running.
The WebSocket transport is not available, you must install a WebSocket server that is compatible with your async mode to enable it. See the documentation for details. (further occurrences of this error will be logged with level INFO)
[2021-12-10 12:57:34 +0800] [4072] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/socket.io/?EIO=4&transport=polling&t=NsYj26-'
Traceback (most recent call last):
  File "handle_request", line 83, in handle_request
    class Sanic(BaseSanic, metaclass=TouchUpMeta):
  File "C:\Users\user\miniconda3\envs\chatbot\lib\site-packages\engineio\asyncio_server.py", line 317, in handle_request
    return await self._make_response(r, environ)
  File "C:\Users\user\miniconda3\envs\chatbot\lib\site-packages\engineio\asyncio_server.py", line 385, in _make_response
    response = make_response(
  File "C:\Users\user\miniconda3\envs\chatbot\lib\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

My RASA version is

Rasa Version      :         3.0.2
Minimum Compatible Version: 3.0.0
Rasa SDK Version  :         3.0.2
Rasa X Version    :         None
Python Version    :         3.8.0
Operating System  :         Windows-10-10.0.19041-SP0

Appreciate if anyone can point out which part I did wrongly.

Thanks

It’s not your problem, check this:

@KHTee can you please refer this thread: Problem with websockets - #14 by nik202 and I hope you uncommented the below code in endpoints.yml

action_endpoint:
  url: 'http://localhost:5055/webhook'

I hope this will solve your issue.

@nik202 Thanks for the solutions. Now the widget is working.

However, my console is printing error message related to web socket. Although it seems like the chatbot still working fine, any idea what went wrong?

[2021-12-13 14:11:39 +0800] [20808] [ERROR] Exception occurred while handling uri: 'http:///*'
Traceback (most recent call last):
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/http.py", line 126, in http1
    await self.http1_request_header()
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/http.py", line 188, in http1_request_header
    await self._receive_more()
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/server.py", line 222, in receive_more
    await self._data_received.wait()
  File "/usr/lib/python3.8/asyncio/locks.py", line 309, in wait
    await fut
asyncio.exceptions.CancelledError
[2021-12-13 14:11:39 +0800] [20808] [ERROR] Exception occurred while handling uri: 'http:///*'
Traceback (most recent call last):
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/http.py", line 126, in http1
    await self.http1_request_header()
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/http.py", line 188, in http1_request_header
    await self._receive_more()
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/server.py", line 222, in receive_more
    await self._data_received.wait()
  File "/usr/lib/python3.8/asyncio/locks.py", line 309, in wait
    await fut
asyncio.exceptions.CancelledError
[2021-12-13 14:11:53 +0800] [20808] [ERROR] Exception occurred while handling uri: 'ws://localhost:5005/socket.io/?EIO=4&transport=websocket&sid=1921fI6Ny7eEu9OmAAAA'
Traceback (most recent call last):
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/app.py", line 782, in handle_request
    raise ServerError(
sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)
[2021-12-13 14:11:53 +0800] [20808] [ERROR] Exception occurred while handling uri: 'ws://localhost:5005/socket.io/?EIO=4&transport=websocket&sid=1921fI6Ny7eEu9OmAAAA'
Traceback (most recent call last):
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/app.py", line 782, in handle_request
    raise ServerError(
sanic.exceptions.ServerError: Invalid response type None (need HTTPResponse)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/http.py", line 129, in http1
    await self.protocol.request_handler(self.request)
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic_plugin_toolkit/realm.py", line 562, in _handle_request_21_03
    raise cancelled
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic_plugin_toolkit/realm.py", line 550, in _handle_request_21_03
    _ = await real_handle(request)
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/app.py", line 791, in handle_request
    await self.handle_exception(request, e)
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/app.py", line 704, in handle_exception
    await response.send(end_stream=True)
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/response.py", line 122, in send
    await self.stream.send(data, end_stream=end_stream)
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/http.py", line 335, in http1_response_header
    await self._send(ret)
  File "/home/isaac/venv/chatbot-rasa/lib/python3.8/site-packages/sanic/server.py", line 268, in send
    raise CancelledError
asyncio.exceptions.CancelledError

Below are the dependencies version

sanic                   21.6.0
sanic-jwt               1.6.0
sanic-plugin-toolkit    1.2.0
sanic-routing           0.7.0

Thanks

@KHTee great!! can you please share me the rasa --version, Sanic-Cors version and command you are using to run the rasa?

@nik202, here you go with the requested info.

Rasa version

Rasa Version      :         3.0.1
Minimum Compatible Version: 3.0.0
Rasa SDK Version  :         3.0.2
Rasa X Version    :         None
Python Version    :         3.8.10
Operating System  :         Linux-5.4.72-microsoft-standard-WSL2-x86_64-with-glibc2.29

Sanic-Cors version

Sanic-Cors              1.0.0

Command to run rasa server

rasa run --enable-api --cors "*"

@KHTee try this command:


rasa run -m models --enable-api --cors "*" --debug

@nik202 still receiving the same error with

rasa run -m models --enable-api --cors "*" --debug

@KHTee are you able to solve this Tee?

@KHTee can I request you to please close this thread as a solution for yourself and for other. Thanks.