I am trying to get real time news data using ERT in cloud and the MRN service. I am using the template code shown here https://github.com/Refinitiv-API-Samples/Example.WebSocketAPI.Python.TestClient in pywstestclient.py, but I added changes so that in the process_message function I added the processMRNUpdate function from https://github.com/Refinitiv-API-Samples/Example.WebSocketAPI.Python.MRN/blob/master/mrn_console_app.py, which is unique to MRN and process the data coming through. I also added code to put the streamed data into a mongo DB. My problem is that after a random amount of time, I would get one of the several errors:
 [ E r r n o   1 0 4 ]   C o n n e c t i o n   r e s e t   b y   p e e r 
  W e b S o c k e t   C l o s e d 
or
C o n n e c t i o n   i s   a l r e a d y   c l o s e d . 
 W e b S o c k e t   C l o s e d 
or 
Traceback (most recent call last):
  File "MRNclient.py", line 348, in <module>
    market_data.reissue_token(ws_app,sts_token)
  File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/bokun/code/Users/Bokun/Refinitive_real_time_data/market_data.py", line 246, in reissue_token
    send_login_request(ws, True)
  File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/bokun/code/Users/Bokun/Refinitive_real_time_data/market_data.py", line 277, in send_login_request
    ws.send(json.dumps(login_json))
  File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/websocket/_app.py", line 154, in send
    if not self.sock or self.sock.send(data, opcode) == 0:
  File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/websocket/_core.py", line 253, in send
    return self.send_frame(frame)
  File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/websocket/_core.py", line 279, in send_frame
    l = self._send(data)
  File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/websocket/_core.py", line 449, in _send
    return send(self.sock, data)
  File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/websocket/_socket.py", line 157, in send
    return _send()
  File "/anaconda/envs/azureml_py36/lib/python3.6/site-packages/websocket/_socket.py", line 139, in _send
    return sock.send(data)
  File "/anaconda/envs/azureml_py36/lib/python3.6/ssl.py", line 944, in send
    return self._sslobj.write(data)
  File "/anaconda/envs/azureml_py36/lib/python3.6/ssl.py", line 642, in write
    return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe
And the stream would stop when the error occur. I understand that this problem would not occur if I do not process the MRN messages and put it on mongoDB but I am wondering why is it causing my streaming to stop? Has anyone else ran into similar problems when trying to process the streamed data (in my case doing the MRN processing and put in to mongoDB)? Also it is weird that one of the 3 errors would occur randomly.
Thank you!