question

Upvotes
3 4 6 10

continuing q-98478, 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

There is a problem with python Refinitiv-Data package 1.0.0b20, there are multiple ' " ' double quote scopes on timeout message (I think it is a bug on Refinitiv Server Side)

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


I managed to workaround this error removing the inner scope:

workarround

  
                
  1.         try:
  2.             json_content=None
  3.             if response and response.text and "\"error\":\"server_error\"" in response.text:
  4.                 print("[REFINITIV HACK ORI] fixing Malformed JSON", end=" ")
  5.                 json_content=json.loads((''.join(response.text.split('\"'))).replace(":","\":\"").replace("  ,","\"  ,\"").replace("{","{\"").replace("}","\"}"))
  6.                 print(json_content)
  7.             else:
  8.                 json_content = response.json()
  9.         except json.decoder.JSONDecodeError:
  10.             message = (
  11.                 f"Malformed JSON received during token refresh: '{response.text}'. "
  12.                 f"Status code: {response.status_code}")
  13.             self.error(message)
  14.             self._callback(UpdateEvent.REFRESH_TOKEN_FAILED, message, {})
  15.             return

now I try to close and restart the session once I get this error message.

but the second attempt to open a stream under the new session fails stating "Session is not open".

                track_last_position_before_exception="refinitiv on position 01"
                if os.name == 'nt':
                    track_last_position_before_exception="refinitiv on position 02"
                    # on "okatz" user on the office desktop win computer
                    # rd.load_config('C:/work/py38/MRMTWebSocketPyKx/configurations/refinitiv-data.config.json')
                    # on "srv" user on the office desktop win computer refinitiv-data_1.config.json
                    rd.load_config('E:/work/enigmajupiter/KFCMR/Configuration/refinitiv-data_1.config.json')
                    # rd.load_config('C:/work/py38/jwt/NathansProject/KxProjectCode/Configuration/refinitiv-data.config.json')
                    track_last_position_before_exception="refinitiv on position 03"
                else:
                    track_last_position_before_exception="refinitiv on position 04"
                    #print("[REFINITIV]: LOADING CONFIG FILE FOR Dev SERVER")
                    #rd.load_config('/home/ubuntu/data_enigma_x_server/distribution_server/RefinitivConf/refinitiv-data_1.config.json')
                    print("[REFINITIV]: LOADING CONFIG FILE FOR DEPLOY SERVER")
                    rd.load_config('/home/ubuntu/enigmajupiter/pyScripts/refinitivdataclient/Configuration/refinitiv-data.config.json')
                    track_last_position_before_exception="refinitiv on position 05"
                track_last_position_before_exception="refinitiv on position 06"
                # FIXME: ORI KOVACSI KATZ 13/10/2022 got an error [REFINITIV ## startListening() function ## ## Generic Exception ##][2022-10-12 15:37:43.125112]: Caught  error: Session must be open
                self.current_rd_session = rd.open_session()
                track_last_position_before_exception="refinitiv on position 07"
                #self.current_rd_session = rd.session.get_default()
                # self.current_rd_session.on_event(self.on_event)
                # , 'CF_LAST', 'TRDPRC_1'
                #self.theWebSocket = rd.content.pricing.Definition(['BTCc1','BTCc2','BTCc3','BTCc4','BTCc5','BTCc6','BTCc7','BTCc8','BTCc9','QBTCu.TO','QETHu.TO','EUR=','GBP=','CADUSD=R','AUD=','CHFUSD=R'], fields=['BID', 'ASK', 'QUOTIM', 'QUOTIM_MS', 'ORDER_SIDE', 'ORDER_PRC', 'ORDER_SIZE', 'BID_SIZE', 'ASK_SIZE', 'CF_LAST']).get_stream()
                self.theWebSocket = rd.content.pricing.Definition([ 'BTC=', 'ETH=', 'HTEc1','HTEc2','HTEc3','HTEc4','HTEc5','HTEc6','HTEc7','HTEc8','HTEc9','BTCc1','BTCc2','BTCc3','BTCc4','BTCc5','BTCc6','BTCc7','BTCc8','BTCc9','QBTCu.TO','QETHu.TO','EUR=','GBP=','CADUSD=R','AUD=','CHFUSD=R'], fields=['MID_1','PRIMACT_1','CLOSE_ASK','CLOSE_BID','PRIM_CLOSE','HST_CLOSE','HSTCLSDATE','MID_PRICE','BID', 'ASK', 'QUOTIM', 'QUOTIM_MS', 'ORDER_SIDE', 'ORDER_PRC', 'ORDER_SIZE']).get_stream()
                track_last_position_before_exception="refinitiv on position 08"
                self.theWebSocket.on_refresh(self.handle_refresh_wrapper)
                track_last_position_before_exception="refinitiv on position 09"
                self.theWebSocket.on_update(self.handle_update_wrapper)
                track_last_position_before_exception="refinitiv on position 10"
                self.theWebSocket.on_status(self.handle_status_wrapper)
                track_last_position_before_exception="refinitiv on position 11"
                self.theWebSocket.on_complete(self.on_complete_wrapper) 
                track_last_position_before_exception="refinitiv on position 12"
                self.theWebSocket.on_error(self.on_error_wrapper)
                track_last_position_before_exception="refinitiv on position 13"
                self.theWebSocket.open()
                track_last_position_before_exception="refinitiv on position 14"
.
.
.
                track_last_position_before_exception="refinitiv on position 17"
                # mark this websocket is running
                self.isRunning = True
                track_last_position_before_exception="refinitiv on position 18"


I can Identify failure with exception on

self.theWebSocket.open()

by setting the

track_last_position_before_exception="refinitiv on position 13"

when accepting exception with message:

[REFINITIV ## startListening() function ## ## Generic Exception ##][2022-10-15 01:26:22.798371]: Caught  error:  Session must be open
refinitiv on position 13


I need help with two things:

1. can I change timeout (HTTP request time out) to a very short one to get this scenario reproduced fast?

it takes a day until I catch it, I need it fast for debugging.


2. how can I troubleshoot the delete and create a new session and a new stream to find out what is wrong with the session when I try open() the stream after I closed it once?


Thanks

Ori Kovacsi Katz




refinitiv-dataplatform-eikonwebsocketstime-outsessiondebugging
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.

Hi @okatz ,

Please be informed that this question is closed as it's duplicated with this question.

1 Answer

· Write an Answer
Upvotes
32.2k 40 11 20

Hello @okatz ,

This question appears to be a duplicate of this question.

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.