Invalid HTTP Method


[2020-01-04 11:59:45 +0530] [17492] [ERROR] Exception occurred while handling uri: unknown Traceback (most recent call last): File “c:\users\saprepc\appdata\local\programs\python\python37\lib\site-packages\sanic\server.py”, line 273, in data_received self.parser.feed_data(data) File “httptools/parser/parser.pyx”, line 193, in httptools.parser.parser.HttpParser.feed_data httptools.parser.errors.HttpParserInvalidMethodError: invalid HTTP method

I get this error on running “rasa run --enable-api -m .\models…” and accessing ‘https://127.0.0.1:5005/webhooks/rest/webhook’ from postman.

It looks like you’re running into an issue associated with a recent update to the sanic library. Please execute the command pip --upgrade sanic~=19.9.0

Due to some previous error encountered, I had already installed sanic==19.9.0. Also tried the upgrade command but it was not helpful. @stephens

Start rasa with the --debug option and paste the output showing the available webserver routes. Can you also paste your credentials.yml file.

Debug :

credentials.yml (1.3 KB)

@stephens Kindly look into this. After a while, I ran into this error again.

New debug file:

Apparently, I was using ‘https’ instead of ‘http’ when making the POST request in postman. Silly :thinking:

I seem to run into this issue as well, but the problem is it is intermittent. Versions: rasa==1.6.1, rasa_sdk==1.6.1, sanic==19.9.0. Worse issue is bot gets frozen, and cannot recover unless restarted. There is only one client connecting to it, and it is managed by our team and only uses http communication.

error log:

[2020-03-09 15:21:58 +0000] [1] [ERROR] Exception occurred while handling uri: unknown
Traceback (most recent call last):
 File "/build/lib/python3.6/site-packages/sanic/server.py", line 273, in data_received
    self.parser.feed_data(data)
  File "httptools/parser/parser.pyx", line 193, in httptools.parser.parser.HttpParser.feed_data
httptools.parser.errors.HttpParserInvalidMethodError: invalid HTTP method
[2020-03-09 15:21:59 +0000] [1] [ERROR] Exception occurred while handling uri: unknown
Traceback (most recent call last):
  File "/build/lib/python3.6/site-packages/sanic/server.py", line 273, in data_received
   self.parser.feed_data(data)
  File "httptools/parser/parser.pyx", line 193, in httptools.parser.parser.HttpParser.feed_data
httptools.parser.errors.HttpParserInvalidMethodError: invalid HTTP method

Startup: (Note we use the wealthBotRestInput (custom channel) to extract some metadata. This is a subclass of the normal Rest channel with the get_metadata method filled up. Thats the only difference.

/webhooks/wealthBotRestInput                       GET                            custom_webhook_WealthBotRestInput.health,
[2020-03-10 00:18:22.675 DEBUG rasa.core.utils:utils.py:250] Available web server routes: ,
/conversations/<conversation_id>/messages          POST                           add_message,
/conversations/<conversation_id>/tracker/events    POST                           append_events,
/webhooks/rasa                                     GET                            custom_webhook_RasaChatInput.health,
/webhooks/rasa/webhook                             POST                           custom_webhook_RasaChatInput.receive,
/webhooks/rest/webhook                             POST                           custom_webhook_RestInput.receive,
/webhooks/rest                                     GET                            custom_webhook_RestInput.health,
/model/test/intents                                POST                           evaluate_intents,
/webhooks/wealthBotRestInput/webhook               POST                           custom_webhook_WealthBotRestInput.receive,
/model/test/stories                                POST                           evaluate_stories,
/domain                                            GET                            get_domain,
/conversations/<conversation_id>/execute           POST                           execute_action,
/socket.io                                         OPTIONS                        handle_request,
/version                                           GET                            version,
/model                                             DELETE                         unload_model,
/webhooks/websocket                                GET                            websocket_webhook.health,
/model/train                                       POST                           train,
/model/predict                                     POST                           tracker_predict,
/status                                            GET                            status,
/conversations/<conversation_id>/tracker           GET                            retrieve_tracker,
/conversations/<conversation_id>/story             GET                            retrieve_story,
/conversations/<conversation_id>/tracker/events    PUT                            replace_events,
/conversations/<conversation_id>/predict           POST                           predict,
/model/parse                                       POST                           parse,
/                                                  GET                            hello,
/model                                             PUT                            load_model,
[2020-03-10 00:18:22.675 INFO root:run.py:183] Starting Rasa server on http://localhost:5005,
[2020-03-10 00:18:22.675 DEBUG rasa.core.utils:utils.py:508] Using the default number of Sanic workers (1).

We are hoping to move this into production very soon, and any help in identifying the issue would really be appreciated. The only solution when the bot encounters this is to restart.