question

Upvotes
3 4 6 10

Failure on OMM stream: Malformed JSON received during token refresh: '{"error":"server_error" ,"error_description":"Request "xxxxxx-yyyyy-zzzz-tttt-sssssssss" has failed on backend call timeout" } '. Status code: 500

Hi Community members.

I really appreciate your support, sorry if this question is to direct, I wish to clarify I don't actually know if it is a bug on Refinitiv Server Backend side, just searching for solution.


Seems like there is an error on Refinitiv server related to the session refresh token process of OMM websocket stream:

I get an error message:

Malformed JSON received during token refresh: '{"error":"server_error" ,"error_description":"Request "xxxxxx-yyyyy-zzzz-tttt-sssssssss" has failed on backend call timeout" } '. Status code: 500


from first look the error might be a good explanation for the bug on the server

:"Request "xxxxxx-yyyyy-zzzz-tttt-sssssssss" has failed on backend call timeout"

the request uuid must be with ' \" ' literal double quotes or without them. - definitly not with plain text ' " ' .

by default, json parser may not parse a value with interleaving double Quates marks.

can you confirm?


If not - please inform me how to fix

Thanks

Ori Kovacsi Katz


EDITED:

using version:

./lib/python3.9/site-packages/refinitiv_data-1.0.0b20.dist-info

used search :

grep -rnw `pwd` -e "Malformed JSON received during token refresh"

on:

~/miniconda3/envs/<environment name>/lib/python3.9/site-packages/refinitiv/data/_core/session/refresh_token_updater.py line 63

I can see location of the failure the "def _on_update(self):" function

        try:
            json_content = response.json()
        except json.decoder.JSONDecodeError:
            message = (
                f"Malformed JSON received during token refresh: '{response.text}'. "
                f"Status code: {response.status_code}")
            self.error(message)
            self._callback(UpdateEvent.REFRESH_TOKEN_FAILED, message, {})
            return

hope this will help to reproduce / resolve the issue

refinitiv-data-platformOMMsession
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 4 6 10

I can confirm this was the cause for Refinitiv OMM web-socket disconnection with

undocumented flow to an error call-back.

as a temporary workaround I tweaked the Refinitiv-Data 1.0.0b20 python package (python client connector) added broth force json parsing

workarround

        try:
            json_content=None
            if response and response.text and "\"error\":\"server_error\"" in response.text:
                print("[REFINITIV HACK ORI] fixing Malformed JSON", end=" ")
                json_content=json.loads((''.join(response.text.split('\"'))).replace(":","\":\"").replace("  ,","\"  ,\"").replace("{","{\"").replace("}","\"}"))
                print(json_content)
            else:
                json_content = response.json()
        except json.decoder.JSONDecodeError:
            message = (
                f"Malformed JSON received during token refresh: '{response.text}'. "
                f"Status code: {response.status_code}")
            self.error(message)
            self._callback(UpdateEvent.REFRESH_TOKEN_FAILED, message, {})
            return

I am not sure it will stand other error messages scenarios, but for now it solved my case, I suspect a bug on Refinitiv server side with multiple literal ' " ' double quate marks on same Json field without escape notation ' \" '

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
25.7k 58 17 14

The latest RD Library version 1.0 is just released this week. The application should upgrade to this version.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.