For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
28 2 3 7

any sample code for WebSocket API SymbolList POST?

does anyone already succeed SymbolList posting via websocket API?

treprdp-apiwebsocketsrrto
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.

Upvotes
Accepted
45.2k 103 44 60

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
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.

Upvotes
45.2k 103 44 60

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
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.

Upvotes
28 2 3 7

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?


slpost.png (29.2 KiB)
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.

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

I will verify the problem.