Test Reader Connection to WebSocket endpoint

When a Web Socket endpoint is configured in the reader and mapped to data endpoint, the reader will act as a Web Socket server accepting client connections on either port 80 or 443 depending on whether or not the security is configured.

WebSocket Client

  • Any WebSocket client app can be used to connect to the reader and read the tag data. An Example of a python websocket client app in given below.

    import websocket
    import ssl
    
    def on_message(ws, message):
        print(message)
    
    def on_error(ws, error):
        print(error)
    
    def on_close(ws, close_status_code, close_msg):
        print("### closed ###")
    
    def on_open(ws):
        print("Opened connection")
    
    if __name__ == "__main__":
        websocket.enableTrace(True)
        ws = websocket.WebSocketApp("wss://10.17.231.142/ws",
                                  on_open=on_open,
                                  on_message=on_message,
                                  on_error=on_error,
                                  on_close=on_close)
    
        ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE, "ssl_version": ssl.PROTOCOL_TLSv1_1})
    
  • The output from the script on connection is as shown below.

    ../../_images/ws_script_connection.png

Interact with Reader

  • To start tag reads and receive tag data please refer to here

  • Once start succeeds the tag data will be sent to the Web Socket client connection.

    ../../_images/ws_connection_data.png