WebSocket Link

Send and receive JSON messages with a server.

WebSocket server, through Connection Service, to Mapped tags in the project.WebSocket serverConnection ServiceMapped tags

Set it up

  1. Start the Connection Service. Stop the PLC and add a WebSocket Link from I/O Links.
  2. On Connection, type the server URL, starting with ws:// or wss://, or click Practice server. Add a login or headers if the server needs them, then click Connect.
  3. On Tags, add receive tags. Each one reads one field of each message, such as amr1.speed. With Message type set, it reads only messages whose type field matches.
  4. Add send tags and write them in your rungs like any tag. Send tags that changed go out together in one message at the end of the scan.

Check before you run

  • Passwords, tokens and header values stay in the Connection Service. They are never saved in the project file.
  • OK is on while good values arrive. It turns off when the Link disconnects, a field is missing or the wrong type, or no message arrives within Stale after.
  • The status tag <Link>_WS has Connected, Error, ErrorCode and LastMessageAge. ErrorCode is 1 can’t reach the server, 2 login refused, 3 certificate not trusted, 4 closed by the server.
  • Import… and Export… use a CSV with the columns Direction, Name, Type, Field, Message type and Deadband.

If it will not connect

Check the Connection Service indicator, the device or server address, and the Link’s diagnostics. A saved mapping does not mean the device is connected. Stop the PLC before changing the Link.

Related