Why are all the urls I filled in my subscription invalid?What format should it be?

SampleSample 中国

The above is the value in the address box below, but the invalid URI is displayed when the form is submitted

If it's typed directly into the url box there's no problem, how do you solve that problem?


Best Answer


  • SampleSample 中国
    dnilsson said:
    Here is an example code of subscription using Python 3. Take a look at the formatting of the URLs. I hope it can give you some guidance.
    import sys, argparse 
    import xml.etree.ElementTree as ET
    from ws4py.client.threadedclient import WebSocketClient
    import requests
    import json
    from requests.auth import HTTPDigestAuth

    namespace = '{http://www.w3.org/1999/xhtml}'

    def print_event(evt):
    root = ET.fromstring(evt)
    if root.findall(".//{0}li[@class='pnl-ctrlstate-ev']".format(namespace)):
    print ("\tController State : " + root.find(".//{0}li[@class='pnl-ctrlstate-ev']/{0}span".format(namespace)).text)
    if root.findall(".//{0}li[@class='pnl-opmode-ev']".format(namespace)):
    print ("\tOperation Mode : " + root.find(".//{0}li[@class='pnl-opmode-ev']/{0}span".format(namespace)).text)
    if root.findall(".//{0}li[@class='pnl-speedratio-ev']".format(namespace)):
    print ("\tSpeed Ratio : " + root.find(".//{0}li[@class='pnl-speedratio-ev']/{0}span".format(namespace)).text)

    class RobWebSocketClient(WebSocketClient):
    def opened(self):
    print ("Web Sockect connection established")

    def closed(self, code, reason=None):
    print ("Closed down", code, reason)

    def received_message(self, event_xml):
    if event_xml.is_text:
    print ("Events : ")
    print ("Received Illegal Event " + str(event_xml))

    class RWPanel:
    def __init__(self, host, username, password):
    self.host = host
    self.username = username
    self.password = password
    self.digest_auth = HTTPDigestAuth(self.username,self.password)
    self.subscription_url = 'http://{0}/subscription'.format(self.host)
    self.session = requests.Session()

    def subscribe(self):
    payload = {'resources':['1','2','3'], '1':'/rw/panel/speedratio', '1-p':'1', '2':'/rw/panel/ctrlstate', '2-p':'1', '3':'/rw/panel/opmode', '3-p':'1'}

    resp = self.session.post(self.subscription_url , auth=self.digest_auth, data=payload)
    print ("Initial Events : ")
    if resp.status_code == 201:
    self.location = resp.headers['Location']
    self.cookie = '-http-session-={0}; ABBCX={1}'.format(resp.cookies['-http-session-'], resp.cookies['ABBCX'])
    return True
    print ('Error subscribing ' + str(resp.status_code))
    return False

    def start_recv_events(self):
    self.header = [('Cookie',self.cookie)]
    self.ws = RobWebSocketClient(self.location, protocols=['robapi2_subscription'], headers=self.header)

    def close(self):
    def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-host",help="The host to connect. Defaults to localhost on port 80", default='localhost:80')
    parser.add_argument("-user",help="The login user name. Defaults to default user name", default='Default User')
    parser.add_argument("-passcode",help="The login password. Defaults to default password", default='robotics')

    if rwpanel.subscribe():

    except KeyboardInterrupt:

    if __name__ == "__main__":
    Thank you for your reply code, carefully watched the processes, including robot signal subscription I understand it, but where the program is to determine whether a state of the signal has been changed, to read the robot again the value of the signal, I play in you program the breakpoint debugging, but every time modify the robot parameters, can jump directly below the code position;

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion