Socket.io missing Access-Control-Allow-Origin header

Hi,

I’m using Docker with images:

  • rasa/rasa:1.7.0-full
  • rasa/rasa-sdk:latest
  • rasa/duckling:latest

Start command

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

Issue

The header Access-Control-Allow-Origin seems to be missing for socket.io:

image

I think this issue may be similar to this one: RASA Core: –cors parameter does not apply to socket.io

I’ve tried the suggestions with no results so far.

Did I miss something?

Same here. Any suggestions please ? @Tobias_Wochinger

@Abdessamad Are you running into any issues? It should definitely work either way.

Hi @Tobias_Wochinger,

I am currently working on a project with @caubin and we get a CORS error when trying to connect the WebChat widget to Rasa… Like explained above !

Do you have any suggestions to make it work ?

Thank you for your time ^^

@akelad can you help us on this issue please ?

Kind regards

@Abdessamad could you post the error logs you’re getting?

From Google Chrome console:

Access to XMLHttpRequest at ‘https://domain.com/socket.io/?EIO=3&transport=polling&t=N2h2Iyj’ from origin ‘null’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

webchat-latest.js:48 GET https://domain.com/socket.io/EIO=3&transport=polling&t=N2h2Iyj net::ERR_FAILED

Thanks,

Kind regards

Can you show the error messages in the rasa logs? And what command are you using to run it?

@akelad Im working with @Abdessamad on this project. Im trying to deploy the rasa docker image into our Azure plateform.

We are running rasa with the command: run -m models --enable-api --cors "*" --debug

To clarify, when calling rasa with Webchat on local system (http://localhost:5005/) we have a null header:

Access-Control-Allow-Origin: null

When calling to Azure deployed rasa (https://azure.domain/) we have no Access-Control-Allow-Origin header and the error:

Access to XMLHttpRequest at 'https://azure.domain/socket.io/?EIO=3&transport=polling&t=N2h2Iyj' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
webchat-latest.js:48 GET https://azure.domain/socket.io/?EIO=3&transport=polling&t=N2h2Iyj net::ERR_FAILED

From rasa logs:

2020-03-09T08:37:18.785913706Z 2020-03-09 08:37:18 DEBUG    rasa.core.channels.socketio  - User db6eb5c90108416b947f73ff77a243fb connected to socketIO endpoint.
2020-03-09T08:37:20.173660981Z 2020-03-09 08:37:20 DEBUG    rasa.core.channels.socketio  - User 140450853525404ba811e9fd71a5d389 connected to socketIO endpoint.
2020-03-09T08:37:21.573446796Z 2020-03-09 08:37:21 DEBUG    rasa.core.channels.socketio  - User e3ade34244aa4981b4c1aa4836680a7e connected to socketIO endpoint.

2020-03-09T08:38:31.823532304Z 2020-03-09 08:38:31 DEBUG    rasa.core.channels.socketio  - User db6eb5c90108416b947f73ff77a243fb disconnected from socketIO endpoint.
2020-03-09T08:38:32.247397831Z 2020-03-09 08:38:32 DEBUG    rasa.core.channels.socketio  - User 140450853525404ba811e9fd71a5d389 disconnected from socketIO endpoint.
2020-03-09T08:38:32.671065458Z 2020-03-09 08:38:32 DEBUG    rasa.core.channels.socketio  - User e3ade34244aa4981b4c1aa4836680a7e disconnected from socketIO endpoint.

Im guessing that in order to make it work on Azure we should have Access-Control-Allow-Origin: * when calling rasa on local.

@caubin do you see a debug message about CORS near the top of the logs?

2020-03-11 10:55:51 DEBUG    rasa.cli.utils  - Parameter 'endpoints' not set. Using default location 'endpoints.yml' instead.
2020-03-11 10:55:51 DEBUG    rasa.model  - Extracted model to '/var/folders/h_/jnhnb5q137x0t5cfbv6cc9hr0000gp/T/tmpqscwbllf'.
2020-03-11 10:55:52 DEBUG    sanic.root  - CORS: Configuring CORS with resources: {'/*': {'origins': ['[*]'], 'methods': 'DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT', 'allow_headers': ['.*'], 'expose_headers': None, 'supports_credentials': True, 'max_age': None, 'send_wildcard': False, 'automatic_options': True, 'vary_header': True, 'resources': {'/*': {'origins': ['[*]']}}, 'intercept_exceptions': True, 'always_send': True}}

@erohmensing We don’t have the mention of CORS configuration in our logs and a far as I remember we never had one.

Log looks like this:

2020-03-11 13:49:32 DEBUG rasa.cli.utils - Parameter 'endpoints' not set. Using default location 'endpoints.yml' instead.
2020-03-11 13:49:32 DEBUG rasa.cli.utils - Parameter 'credentials' not set. Using default location 'credentials.yml' instead.
2020-03-11 13:49:32 DEBUG rasa.core.utils - Available web server routes:
<routes>
2020-03-11 13:49:32 INFO root - Starting Rasa server on http://localhost:5005
2020-03-11 13:49:32 DEBUG rasa.core.utils - Using the default number of Sanic workers (1).
2020-03-11 13:49:32 INFO root - Enabling coroutine debugging. Loop id 94081157252232.
2020-03-11 13:49:32 DEBUG rasa.model - Extracted model to '/tmp/tmpnteaadq8'.
2020-03-11 13:49:43 INFO rasa.nlu.components - Added 'SpacyNLP' to component cache. Key 'SpacyNLP-fr'.
/build/lib/python3.6/site-packages/rasa/nlu/classifiers/embedding_intent_classifier.py:202: FutureWarning: Intent tokenization has been moved to Tokenizer components. Your config still mentions 'intent_tokenization_flag'. Tokenization may fail if you specify the parameter here. Please specify the parameter 'intent_tokenization_flag' and 'intent_split_symbol' in the tokenizer of your NLU pipeline
self._check_old_config_variables(self.component_config)
/build/lib/python3.6/site-packages/rasa/nlu/classifiers/embedding_intent_classifier.py:202: FutureWarning: Intent tokenization has been moved to Tokenizer components. Your config still mentions 'intent_split_symbol'. Tokenization may fail if you specify the parameter here. Please specify the parameter 'intent_tokenization_flag' and 'intent_split_symbol' in the tokenizer of your NLU pipeline
2020-03-11 13:49:44 DEBUG rasa.core.tracker_store - Connected to InMemoryTrackerStore.
2020-03-11 13:49:44 DEBUG rasa.core.lock_store - Connected to lock store 'InMemoryLockStore'.
2020-03-11 13:49:44 DEBUG rasa.model - Extracted model to '/tmp/tmpy1njd9z1'.
2020-03-11 13:49:44 DEBUG pykwalify.compat - Using yaml library: /build/lib/python3.6/site-packages/ruamel/yaml/__init__.py
2020-03-11 13:49:46 DEBUG rasa.core.nlg.generator - Instantiated NLG to 'TemplatedNaturalLanguageGenerator'.

Hello @erohmensing,

Any idea how to solve this issue ?

Kind regards

Please @Abdessamad could you share your html integration for rasa-webchat

Also share with us your endpoint.yml file

index.html (1.2 KB) endpoints.yml (1.4 KB)

Im working with @Abdessamad, you can find the 2 files requested in attachment.

Please @caubin add this at the end of your endpoints.yml file

 socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

@wabi We have this part in our credentials.yml file, which is the correct one?

Rasa log with socketio conf in endpoints.yml:

rasa_1 | sanic.exceptions.NotFound: Requested URL /socket.io/ not found
rasa_1 | [2020-03-20 10:58:42 +0000] [1] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/socket.io/?EIO=3&transport=polling&t=N3tc5n-'

FYI we have in our credentials.yml file:

rest:
  # you don't need to provide anything here - this channel doesn't
  # require any credentials
socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: false
rasa:
  url: "http://rasa:5005/api"

hey @caubin, just start the rasa server using this command:

rasa run -m models --enable-api --cors “*” --debug

@JiteshGaikwad We already use this command to start rasa (see my 1st post).

Please read the discussion before :slight_smile: That is exactly the command we are using to run Rasa !