ERROR rasa.core.channels.rasa_chat - Failed to fetch JWT public key from URL 'http://localhost:5002/api/version' with status code 500

Rasa and Rasa-x installed and run from cli, but web app give me errors when ‘trying to talk with’ bot. I never had to logon

2019-10-02 16:28:48 ERROR    sanic.root  - Exception occurred while handling uri: 'http://localhost:5002/api/version'
Traceback (most recent call last):
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\sanic\app.py", line 917, in handle_request
    response = await response
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\rasax\community\api\blueprints\project.py", line 94, in version
    return response.json(result)
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\sanic\response.py", line 220, in json
    dumps(body, **kwargs),
  File "c:\programdata\anaconda3\envs\rasa\lib\json\__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "c:\programdata\anaconda3\envs\rasa\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "c:\programdata\anaconda3\envs\rasa\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "c:\programdata\anaconda3\envs\rasa\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable
2019-10-02 16:28:48 ERROR    rasa.core.channels.rasa_chat  - Failed to fetch JWT public key from URL 'http://localhost:5002/api/version' with status code 500:
    <h1>Internal Server Error</h1>
    <p>
        The server encountered an internal error and cannot complete
        your request.
    </p>

2019-10-02 16:28:48 ERROR    rasa.core.channels.rasa_chat  - Failed to decode bearer token.
Traceback (most recent call last):
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\rasa\core\channels\rasa_chat.py", line 86, in _decode_bearer_token
    return self._decode_jwt(bearer_token)
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\rasa\core\channels\rasa_chat.py", line 77, in _decode_jwt
    authorization_header_value, self.jwt_key, algorithms=self.jwt_algorithm
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\jwt\api_jwt.py", line 92, in decode
    jwt, key=key, algorithms=algorithms, options=options, **kwargs
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\jwt\api_jws.py", line 156, in decode
    key, algorithms)
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\jwt\api_jws.py", line 220, in _verify_signature
    key = alg_obj.prepare_key(key)
  File "c:\programdata\anaconda3\envs\rasa\lib\site-packages\jwt\algorithms.py", line 209, in prepare_key
    raise TypeError('Expecting a PEM-formatted key.')
TypeError: Expecting a PEM-formatted key.

Hi @Charlesjwilliams2, what OS are you running? What versions of rasa and rasa x are you running?

Hi,

There can be a problem in jwt.py python file in rasa X. In this file, add_jwt_key_to_result method return key as byte array.

add below code for this function

results[“keys”][0][“key”] = results[“keys”][0][“key”].decode(“utf-8”)

Hi @mribrahim, you’re right in that the key should indeed be decoded before being returned as json. I’m still curious about OP’s OS because this doesn’t seem to happen on unix-based operating systems (seems like it’s Windows)

@Charlesjwilliams2 we’ve just released rasa X 0.21.3 in which this bug should be fixed. Would you mind upgrading to that version?

pip install rasa-x --extra-index-url https://pypi.rasa.com/simple --upgrade

I reinstalled from scratch into an Anaconda deployment on my Windows10 machine. this time, though I noticed that there was a problem related to install of the httptools package. I conda install -c conda-forge httptools before running pip install rasa-x --extra-index-url https://pypi.rasa.com/simple and everything works well enough to run rasa x. I will also try the pip install rasa-x --extra-index-url https://pypi.rasa.com/simple --upgrade as well.