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