Websocket API Future finished exception code=1001, reason='Going Away'

Hi,
I am testing to receive underlying options from a chain using the WebSocketAPI with Python in Windows.
Error message:
"Future exception was never retrieved
future: <Future finished exception=ConnectionClosedOK(Close(code=1001, reason='Going Away'), Close(code=1000, reason=''), False)>
websockets.exceptions.ConnectionClosedOK: sent 1000 (OK); then received 1001 (going away) Going Away"
It fails each time on loop 977.
Any advise on the meaning of this error and a possible resolution is appreciated. Simple code enclosed below (removed connection details):
import asyncio
import json
import socket
import websockets
hostname = ''
port = ''
ws_address = "ws://{}:{}/WebSocket".format(hostname, port)
user = ''
app_id = ''
position = socket.gethostbyname(socket.gethostname())
login_json = {
'ID': 1,
'Domain': 'Login',
'Key': {
'Name': '',
'Elements': {
'ApplicationId': '',
'Position': '' }
}
}
login_json['Key']['Name'] = user
login_json['Key']['Elements']['ApplicationId'] = app_id
login_json['Key']['Elements']['Position'] = position
async def hello(initial_name):
store = []
#websocket vs websockets
async with websocket.connect(ws_address, extra_headers={'User-Agent': 'Python'},
subprotocols=['tr_json2'], ping_timeout=None, ping_interval=5) as websocket:
await websocket.send(json.dumps(login_json))
await websocket.recv()
async def get_data_for_name(message):
await websocket.send(json.dumps({
'ID': 2,
'Key': {
'Name': message,
'Service': '$svc',
},
"Streaming": False }))
res = await websocket.recv()
json_res = json.loads(res[1:-1])
store.append(json_res)
print(json_res)
if len(json_res['Fields']['BR_NEXTLR']) > 0:
await get_data_for_name(json_res['Fields']['BR_NEXTLR'])
await get_data_for_name(initial_name)
asyncio.run(hello('0#$chain'))
Kind regards,
Johan
Best Answer
-
Thanks for reaching out to us.
The Refinitiv Real-Time WebSocket has its own ping/pong mechanism. The application will receive a ping message and it needs to send a pong message back to the server.
Recieved:
{
"Type": "Ping"
}
Sent:
{
"Type": "Pong"
}Therefore, you need to remove the ping_timeout and ping_interval settings from the WebSocket connection.
async with websockets.connect(ws_address, extra_headers={'User-Agent': 'Python'},
subprotocols=['tr_json2']) as websocket:I am unable to replicate the error. Please share the chain RICs that you are using.
I hope that this information is of help.
0
Answers
-
Thank you @Jirapongse,
It didn't help instead I got:
"websockets.exceptions.ConnectionClosedError: sent 1011 (unexpected error) keepalive ping timeout; no close frame received"
Adding back ping_timeout=None and I get the other error:
future: <Future finished exception=ConnectionClosedOK(Close(code=1001, reason='Going Away'), Close(code=1000, reason=''), False)>
websockets.exceptions.ConnectionClosedOK: sent 1000 (OK); then received 1001 (going away) Going Away.
I guess this would be the same for any Chain RIC with more than 977 BR_NEXTLR? In my specific case it is actually towards Bloomberg's 0#bgBBG000H4FSM0 via Bloomberg MFA pipe to TREP.
Kind regards,
Johan
0 -
As I know, the Refinitiv Real-Time WebSocket has its own ping/pong mechanism. It doesn't rely on the ping mechanism in the WebSocket.
If I set "ping_interval=5" in the WebSocket, I get an error because the server doesn't recognize the WebSocket internal ping messages.
However, you may need to contact the server team to verify its settings and the reason for the disconnection.
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 629 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 86 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛