Rasa Chat Widget and Google Compute Engine (Websockets)

Hello!

I have Rasa Open Source set up on an instance of Google Cloud - Compute Engine with a fixed IP. I am trying to set up an interface to it using the Rasa Chat Widget. I have set up a Socket Channel in my configuration and I have created firewall rules in my Google instance. However, the channel does not launch, and I cannot connect to it from my the Chat Widget. I am not sure what I am missing?

the channel does not launch

By launch do you mean that you don’t see the /socket.io endpoint when rasa starts?

Here’s an example from a 3.x bot of mine, showing that my /socket channel has started. Enable --debug and make sure you are seeing the channel start. Sounds like it isn’t starting which would mean that your credentials.yml file is not being read in the compute engine instance.

2022-03-30 03:26:42 DEBUG    rasa.core.utils  - Available web server routes: 
/webhooks/twilio_voice                             GET                            Twilio_voice_webhook.health
/webhooks/twilio_voice/webhook                     POST                           Twilio_voice_webhook.receive
/conversations/<conversation_id:path>/messages     POST                           add_message
/conversations/<conversation_id:path>/tracker/events POST                           append_events
/auth                                              POST                           auth_bp.AuthenticateEndpoint
/auth/me                                           GET                            auth_bp.RetrieveUserEndpoint
/auth/verify                                       GET                            auth_bp.VerifyEndpoint
/webhooks/rest                                     GET                            custom_webhook_RestInput.health
/webhooks/rest/webhook                             POST                           custom_webhook_RestInput.receive
/model/test/intents                                POST                           evaluate_intents
/model/test/stories                                POST                           evaluate_stories
/conversations/<conversation_id:path>/execute      POST                           execute_action
/domain                                            GET                            get_domain
/socket.io                                         POST                           handle_request
/                                                  GET                            hello
/model                                             PUT                            load_model
/model/parse                                       POST                           parse

I also wrote a recent blog post on an easy way to test the Rasa socket.io channel.

Hello,

@stephens Thanks for your message, this is very helpful! I can see now my socket.io channel is running

2022-04-04 12:11:30 DEBUG    rasa.core.utils  - Available web server routes:
/webhooks/rasa                                     GET                            custom_webhook_RasaChatInput.health
/webhooks/rasa/webhook                             POST                           custom_webhook_RasaChatInput.receive
/webhooks/rest                                     GET                            custom_webhook_RestInput.health
/webhooks/rest/webhook                             POST                           custom_webhook_RestInput.receive
/socket.io                                         POST                           handle_request
/                                                  GET                            hello
/webhooks/socketio                                 GET                            socketio_webhook.health

But I am just getting the message:

"The client is using an unsupported version of the Socket.IO or Engine.IO protocols"

I am using version 5.5.2 of python-socketio on my server, do you know what version I need to be compatible?

As an aside, I see from your blog post you have used botfront’s webchat, I am also trying to work with this product, but unlike the rasa widget when I embed webchat I don’t see anything on my webpage.

There’s an older incompatibility that you could be running into. You’ll find it mentioned here.

I prefer the Botfront widget because it’s open source and there appears to be more active discussion and support for it.

@stephens Thanks for the response! It does look like this incompatibility issue was part of Rasa 2.3 and 2.4, and can be resolved by upgrading. However, I am already using Rasa 2.8, so I am unsure what the issue is?

EDIT: I am also trying this with Rasa 3.1 to no avail.

EDIT 2: Okay, so running rasa with rasa run -m models --enable-api --cors "*" --debug specifically has addressed the websocket issue! However, I am not getting a new error:

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

and I am getting no response from my bot.

  • correction my websocket is now connecting but the version incomaptaibility remains.

I’ll send you a message if you’d like me to review this on a zoom call.

@arabellastrange I can see you are struggling on this, if you can provide me with some basic information. I hope that will solve your issue.

  1. What is your front-end? Can you share the code snippet with me?
  2. What is your Operating System, Linux or Windows?
  3. Can you share the pip list for the Sanic Version?

I know you have mentioned some details already, but I just want to see that you still following the same?

Note: Rasa 3.x will not work in python 3.6 it will only support on python 3.7 and 3.8. Do tag me @ nik202.

Some linked threads for your ref:

  1. Rasa 3.x problem using official widget - #2 by ILG2021
  2. Problem with websockets

I hope this will be able to solve your issue on your own. Good Luck!

Hi! @nik202

Thanks for the help!

For the frontend I’ve tried both the Rasa Widget and Botfront, so it looks like so:

I am working in Linux on my Compute Engine Instance with Python 3.9 and Rasa 3.1.

For Sanic I have the following: image

@arabellastrange It will never work as you are using rasa 3.1 with python 3.9, please use Rasa 3x with python 3.7 or 3.8. Ref: Installation

Make necessary changes and try and do let me know.

Good Luck!

@nik202 I’ve downgraded my python version

However, my /socket.io port is still returning the same message

And I have no response from my bot image

With this error from Rasa:

1 Like

@arabellastrange have you seen my mentioned threads? This is related to sanic version compatibility with Rasa 3.X. I highly recommend seeing my suggested thread, you will get all your answers in that.

@nik202 I can’t really downgrade Sanic however, since Rasa 3.1 requires a minimum 21.13, see error below:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
rasa 3.1.0 requires sanic<21.13,>=21.12, but you have sanic 21.6.0 which is incompatible.
rasa 3.1.0 requires sanic-cors<3.0.0,>=2.0.0, but you have sanic-cors 1.0.0 which is incompatible.
rasa 3.1.0 requires sanic-routing<0.8.0,>=0.7.2, but you have sanic-routing 0.7.0 which is incompatible.
rasa-sdk 3.1.1 requires sanic<22.0.0,>=21.12.0, but you have sanic 21.6.0 which is incompatible.
rasa-sdk 3.1.1 requires Sanic-Cors<3.0.0,>=2.0.0, but you have sanic-cors 1.0.0 which is incompatible.
1 Like

@arabellastrange try to use --use-feature=2020-resolver ??

If you like you can see the version I have mentioned the most, my be that will help?

Honestly, I have not worked on 3.0 yet and for this issue only I tried with 3.0.1 as shown in my thread posts.

@nik202 Okay, I downgraded to Rasa 3.0 however this doesn’t solve my problems, in your thread it says this set up

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

works for Rasa 3 but when I try to install it pip tells me I need sanic-routing==0.7.2 minimum for Rasa, which means I have to upgrade Sanic, because version 21.6.0 only supports up to 0.7.0. It seems Sanic==21.9.3 may be acceptable, but running rasa run -m models --debug --enable-api --cors "*" now returns

2022-04-07 14:33:42 DEBUG    urllib3.connectionpool  - Starting new HTTPS connection (1): o251570.ingest.sentry.io:443
TypeError: add() takes 3 positional arguments but 4 were given
2022-04-07 14:33:42 DEBUG    urllib3.connectionpool  - https://o251570.ingest.sentry.io:443 "POST /api/2801673/store/ HTTP/1.1" 200 41

any idea where this is coming from?

@stephens I’d highly recommend to do it as fresh process now.

@nik202 I am not sure, I know what you mean? Reinstall rasa? Or reset the server?

@arabellastrange create the fresh conda env, installed the suggested thread version and use botfront widget and try to talk to the bot. If stuck, do let me know, please.

@nik202 I have reinstalled from scratch my venv environment, this is my current set up:

Trying to run my rasa model fails with the same error above:

 python3.8 -m rasa run --model <model_name>.tar.gz --enable-api --cors --debug
  File "/home/.local/lib/python3.8/site-packages/rasa/core/run.py", line 103, in configure_app
    app = server.create_app(
  File "/home/.local/lib/python3.8/site-packages/rasa/server.py", line 664, in create_app
    async def handle_error_response(
  File "/home/.local/lib/python3.8/site-packages/sanic/mixins/exceptions.py", line 36, in decorator
    self._apply_exception_handler(future_exception)
  File "/home/.local/lib/python3.8/site-packages/sanic/app.py", line 356, in _apply_exception_handler
    self.error_handler.add(exception, handler.handler, route_names)
TypeError: add() takes 3 positional arguments but 4 were given

Running models with the default versions installed with Rasa 3.0 returns the same socket incompatibility issue discussed previously.

1 Like

I think we have some incompatible packages I installed this version in my environment and look the versions of my packages

Rasa Version      :         3.0.0
Minimum Compatible Version: 3.0.0
Rasa SDK Version  :         3.0.2
sanic==21.6.0
Sanic-Cors==1.0.0
sanic-jwt==1.7.0
sanic-plugin-toolkit==1.2.1
sanic-routing==0.7.0

Can you try this commands and check again?

pip install rasa-sdk==3.0.2 --no-cache-dir
pip install sanic==21.6.0 --no-cache-dir
pip install sanic-routing==0.7.0 --no-cache-dir

All my package version requirements.txt (8.6 KB)

I dont know why but your env still get other installation. Did you delete the environment using conda env remove -n ENV_NAME or sudo rm -rf ENV_NAME ?

Correct is: --cors "*"
:smiley:

@itsjhonny

In my previous reply I have simply created a new server instance and reinstalled there, in this case I have deleted my environment and reinstalled everything from your attached requirements.txt and I have arrived at the same conflict:

The conflict is caused by:
    The user requested sanic-routing==0.7.0
    sanic 21.6.0 depends on sanic-routing==0.7.0
    rasa 3.0.0 depends on sanic-routing<0.8.0 and >=0.7.2

I am considering reporting this as a bug on the git repo if you are able to possibly replicate this issue?