any sample code for WebSocket API SymbolList POST?

does anyone already succeed SymbolList posting via websocket API?

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    This appears to be expected
    behavior from the ADS when a WebSocket App Posts data with the key primitive
    type of Buffer. The workaround is using AsciiString as the key primitive type. With this type, the data was properly consumed/displayed by both WebSocket and RSSL consumers.

    def send_symbol_list_post(ws):
    global post_id
    sl_post_json = {
    'ID': 1,
    'Type':'Post',
    'Domain':'SymbolList',
    'Key':{
    'Name': "SYM"
    },
    'Ack':True,
    'PostID':post_id,
    'PostUserInfo': {
    'Address':position, # Use IP address as the Post User Address.
    'UserID':os.getpid() # Use process ID as the Post User Id.
    },
    'Message': {
    'ID': 257,
    'Type':'Refresh',
    'Domain':'SymbolList',
    'Key':{
    'Name': "SYM",
    'NameType': "Ric"
    },
    'Solicited': False,
    'Complete' : True,
    'ClearCache' : True,
    'State':{
    'Stream': 'Open',
    'Data': 'Ok',
    'Code' : 'None'
    },
    "Map":{
    "Entries":[
    {
    "Action":"Add",
    "Key":"RIC1"
    },{
    "Action":"Add",
    "Key":"RIC2"
    },
    {
    "Action":"Add",
    "Key":"RIC3"
    }
    ],
    "KeyType":"AsciiString",
    }
    }
    }
    ws.send(json.dumps(sl_post_json))
    print("SENT:")
    print(json.dumps(sl_post_json, sort_keys=True, indent=2, separators=(',', ':')))
    post_id += 1

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    Yes, I can use off-stream posting to post SymbolList to cache in ADS. You need to have a service that can accept post. The following is code in Python.

    def send_symbol_list_post(ws):
    global post_id
    sl_post_json = {
    'ID': 1,
    'Type':'Post',
    'Domain':'SymbolList',
    'Key':{
    'Name': "SYM"
    },
    'Ack':True,
    'PostID':post_id,
    'PostUserInfo': {
    'Address':position, # Use IP address as the Post User Address.
    'UserID':os.getpid() # Use process ID as the Post User Id.
    },
    'Message': {
    'ID': 257,
    'Type':'Refresh',
    'Domain':'SymbolList',
    'Key':{
    'Name': "SYM",
    'NameType': "Ric"
    },
    'Solicited': False,
    'Complete' : True,
    'ClearCache' : True,
    'State':{
    'Stream': 'Open',
    'Data': 'Ok',
    'Code' : 'None'
    },
    "Map":{
    "Entries":[
    {
    "Action":"Add",
    "Key":"RIC1"
    },{
    "Action":"Add",
    "Key":"RIC2"
    },
    {
    "Action":"Add",
    "Key":"RIC3"
    }
    ],
    "KeyType":"Buffer",
    }
    }
    }
    ws.send(json.dumps(sl_post_json))
    print("SENT:")
    print(json.dumps(sl_post_json, sort_keys=True, indent=2, separators=(',', ':')))
    post_id += 1
  • Thank you very much for sharing the idea. The data was posted. But when I consume the symbollist, seeing "D" for Name instead of "RIC1" (Xwindow) and other chars on putty. What am I missing?

    image

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    I got the same issue when subscribing with RSSL 14002. I work fine with WebSocket API.

    I will verify the problem.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.