Skip to content

Live data socket (/ws)

eaxScadaReferenceStarterProEnterpriseView as Markdown

The Studio and the operator runtime receive live values on the /ws WebSocket: tags, alarms, audit events and system messages. This page gives the tag messages, which a browser subscribes per view. How it works and what it means for screens: How live values reach screens. Who may open the socket (sign-in, the Origin check, the socket caps): Security and 21 CFR Part 11, section 7.

Every message is one JSON text frame with a type. The server sends a socket no tag value until a view subscribes the tag.

The browser sends two messages. The server ignores any other type.

{"type": "SUBSCRIBE", "id": 7, "view_id": "page:/line2", "tags": ["Plant/Line2/P101.Current", "Plant/Line2/P101.Running"], "append": false}
Field Meaning
id Any JSON value; the server repeats it in its answer. Optional
view_id The view: a page, a popup, a dock, a 3D or isometric view, a preview, a dialog, a widget. 1 to 128 bytes of valid UTF-8
tags Tag paths, exact, or prefixes ending in /* (see Prefixes). A path is at most 512 bytes of valid UTF-8; an empty path or a repeated one is skipped
append false (or absent): the list replaces the view’s tags, as on a navigation. true: the list is added to the view’s tags (a long list sent in parts)
remove With append: true only (ignored on a replace): paths or prefixes the view lets go. They are applied before tags. Optional

A replace releases the view’s old tags first, so a navigation is never limited by the page it leaves. A tag kept from the old set stays subscribed without a gap.

A page switch as a difference. With append: true and remove, one message changes a view’s set in place: the paths in remove are released (unless another view of the socket, a popup or an inner screen, still holds them), then the paths in tags are added and snapshotted. The tags the view keeps stay subscribed and get no new snapshot. The runtime sends a page switch this way when the server already holds the view and the new page’s tag list needs more than one frame: the leavers first, then the joiners, in parts of at most 48 KiB. A list of one frame is still sent whole, as a replace. A client that sends only replaces, in parts, still works: the later parts snapshot again what the first part released. For two pages of 20,000 tags that share 15,000, a switch snapshots 5,000 tags instead of up to 20,000 and sends about half as much to the server.

{"type": "SUBSCRIBE", "id": 9, "view_id": "page:main", "append": true, "remove": ["Plant/Line2/P101.Current"], "tags": ["Plant/Line3/P301.Current"]}

An entry of tags that ends in /* is a prefix: the view subscribes every tag under that path that the user may read, now and created later.

{"type": "SUBSCRIBE", "id": 10, "view_id": "page:/line1", "tags": ["Plant/Line1/*", "Site2/Tank3/Level"]}
  • Expanded at subscribe time. The server takes the tags under Plant/Line1/ and checks each one with the user’s read rights as an exact path, as if the client had listed it. The readable ones join the view: they share its tag limit and its snapshot.
  • Unreadable tags are counted, never named. A tag under the prefix that the user may not read is neither subscribed nor sent: it is only a number in the prefix’s summary. Its path is not in refused, because the client did not name it.
  • Tags created later. The view keeps holding the prefix. A tag created under it later is checked the same way and, if readable, added to the view with a TAG_SNAPSHOT of its own whose id is null, sent before any update of that tag. A new tag the user may not read is not announced. The server looks for new tags when a value changes and at least once a second.
  • Valid prefixes. * or /* alone, a prefix that starts with /, holds //, or has * or > before the final /*, and one longer than 512 bytes are refused: the entry comes back in refused, with an error in its summary, and nothing is subscribed for it.
  • At most 16 prefixes per view (server.ws_max_prefixes, 1 to 256). A prefix past it is refused with the error “too many prefixes in this view”.
  • The tag limit. The tags a prefix gives count against server.ws_max_tags. The ones past it are not subscribed: the prefix is listed in limited, and its summary counts them.
  • Releasing. remove and UNSUBSCRIBE take a prefix as they take a path. A tag the view holds only through a prefix goes with the last prefix of the view that covers it; a tag the view also lists itself stays. A path in remove that a prefix of the view still covers stays subscribed through the prefix.

The answer to a SUBSCRIBE with prefix entries adds prefixes, one summary per entry:

{"type": "TAG_SNAPSHOT", "id": 10, "view_id": "page:/line1", "tags": [...], "unknown": [], "refused": [], "limited": [],
"prefixes": [{"prefix": "Plant/Line1/*", "taken": 212, "held": 0, "refused": 4, "limited": 0}]}
Member Meaning
prefix The entry as sent
taken Tags newly subscribed through it
held Tags under it the view already held
refused Tags under it the user may not read (a count only)
limited Readable tags under it over server.ws_max_tags
error Why the entry was refused (then it is in refused and subscribes nothing)

A TAG_SNAPSHOT with id null for tags created later carries the same prefixes member, counting the new tags under each prefix. It is sent only when the view took a tag or one was over the limit.

{"type": "UNSUBSCRIBE", "id": 8, "view_id": "page:/line2"}

The view closed: its tags and prefixes are released unless another view of the socket holds the tags. There is no answer.

The answer to a SUBSCRIBE: the current value of each tag the view newly holds.

{"type": "TAG_SNAPSHOT", "id": 7, "view_id": "page:/line2",
"tags": [{"index": 12, "path": "Plant/Line2/P101.Current", "value": 14.2, "quality": 192, "quality_name": "Good", "timestamp": 1763200000000000000, "deadband": 0.05, "eng_unit": "A", "description": "P101 motor current"}],
"unknown": [], "refused": ["Plant/Line2/P101.Running"], "limited": []}
Field Meaning
id, view_id As in the SUBSCRIBE
tags The full tag of each path the view newly holds and the server knows: index, path, value, quality, quality_name, timestamp (Unix nanoseconds), deadband, eng_unit, description, and when set quality_reason (why the tag is Bad or out of service, see r), is_text (a String tag: value is its text) and simulated (the value comes from a simulated source: an accepted simulated eaxPLC or a simulated eaxTag, see s). A tag already held by the view before is not sent again
unknown Paths the user may read that the server does not have. They stay subscribed: a tag created later is sent when it changes
refused Paths the user may not read, or that are too long or not valid UTF-8. They are not subscribed and their value is never sent
limited Paths over the socket’s tag limit (server.ws_max_tags). They are not subscribed. A prefix some of whose tags were over the limit is listed here too
prefixes Only when the SUBSCRIBE held prefix entries: what each one gave (Prefixes)

A value that JSON cannot carry (NaN, infinity) is sent as null with Bad quality, quality_name “Bad (value not representable)”, never as Good.

A TAG_SNAPSHOT whose encoding exceeds 1 MiB (a prefix of a large plant area, for example) is sent in several frames, each at most 1 MiB (17 November). A snapshot that fits in one frame is sent exactly as before, without the members below, so a client that does not know them reads it unchanged.

{"type": "TAG_SNAPSHOT", "id": 7, "view_id": "page:/area", "part": 1, "parts": 3, "more": true,
"tags": [...], "unknown": [], "refused": [], "limited": []}
Field Meaning
part The part’s number, from 1
parts How many parts the answer has
more true on every part but the last, false on the last
id, view_id Those of the SUBSCRIBE, on every part
tags, unknown, refused, limited Spread over the parts in this order: the answer is their concatenation, every entry once
prefixes The per-prefix counts, on the last part only
  • The answer is complete on the last part (more false). The runtime’s own client applies each part’s tags as they come, but treats the request as answered only on the last part: a held screen stays held, the prefix counts are taken, and tags not in yet under a prefix are not withdrawn as “not subscribed” before it.
  • No TAG_UPDATES comes between the parts of one snapshot; an alarm or system message may.
  • A part holds at least one entry, so a single tag larger than 1 MiB still goes, alone in its part.

The changes of the socket’s subscribed tags, sent once per batch window (server.ws_batch_ms, 100 ms by default) when something changed.

{"type": "TAG_UPDATES", "tags": [{"p": "Plant/Line2/P101.Current", "v": 14.6, "q": 192, "qn": "Good", "t": 1763200000100000000}]}
Field Meaning
p The tag path
v The value: a number, a String tag’s text, or null when JSON cannot carry it (then never Good quality)
q, qn The quality code and its name
t The timestamp, Unix nanoseconds
r The quality reason, when there is one: only on a Bad or out-of-service quality, and cleared by the tag’s next write. For example “runtime stopped (Free edition session ended)”, or for a local tag fed by an eaxPLC “eaxPLC node not reporting”, “script id not running on eaxPLC node” or “script id no longer runs on eaxPLC node” (Tags fed by an eaxPLC that stops reporting). A Bad reading from a driver carries none
x 1: a String tag (v is text)
s 1: a simulated value, from an accepted simulated eaxPLC or an eaxTag defined "simulated": true (Tag definition)

A frame holds only the latest change of each tag since the last frame, with that change’s own quality and timestamp. It carries no unit or description: those come with the snapshot. A TAG_SNAPSHOT is always sent before any TAG_UPDATES that carries a later change of its tags. A tag released meanwhile is left out.

A batch over 1 MiB goes in several TAG_UPDATES frames (17 November), sent one after the other in the same batch window. They carry no part markers: each holds whole changes of distinct tags and applies on its own.

A socket whose writer is behind has at most two TAG_UPDATES frames waiting; the changes after them keep merging, so the next frame holds the newest values.

{"type": "SUBSCRIBE_REFUSED", "id": 9, "view_id": "popup:P101", "reason": "rate"}

The message was not applied. reason:

reason When
malformed message The frame is not JSON of this shape (id is then null and view_id empty)
rate Over the message rate (below)
invalid view_id view_id empty, longer than 128 bytes or not valid UTF-8
too many views A new view over the socket’s view limit (server.ws_max_views)

Refusals are logged as “WebSocket subscription refused”, with the reason and the user, at most once every 10 seconds per socket.

{"type": "HEARTBEAT", "every_ms": 5000}

Sent every 5 s on every socket, whatever else the socket gets (29 November). It is written beside the send queue, not through it: a full queue never holds it back. It carries nothing but the interval, so it is sent whatever the user may read.

Field Meaning
every_ms The server’s interval between two heartbeats, in milliseconds

The server sent nothing on an idle socket before (no tag changing, no alarm), so a browser could not tell a quiet link from a dead one that never closed. The page’s client uses the heartbeat to find a silent link (A link that goes silent). A client of the socket that does not need it ignores it; a page from before this release dispatches it as scada:heartbeat and does nothing with it.

Unchanged by the subscriptions, and sent whatever is subscribed (each filtered by the user’s read rights): ALARM_INIT when the socket opens, ALARM_EVENT, AUDIT_EVENT, BATCH_UPDATE, HITL_STAGED, SCREEN_SAVED and the other system messages.

TAG_INIT (every readable tag of the project when the socket opened) and TAG_UPDATE (one message per change of any readable tag) are no longer sent. A client that relied on them sends SUBSCRIBE for the tags it shows.

Limit Value Past the limit
A frame from the browser 64 KiB The socket is closed with 1009
A TAG_SNAPSHOT or TAG_UPDATES frame from the server 1 MiB A snapshot goes in parts (A snapshot in parts), a batch in several frames
Messages from the browser (SUBSCRIBE, UNSUBSCRIBE) 20 a second, with a burst of 40, per socket SUBSCRIBE_REFUSED rate; the message is not applied
Tags one socket holds (all its views together, each path once) server.ws_max_tags, default 50,000, at most 500,000 The paths past it come back in limited
Views one socket holds server.ws_max_views, default 256, at most 4,096 SUBSCRIBE_REFUSED too many views
Prefix entries one view holds server.ws_max_prefixes, default 16, 1 to 256 The entry comes back in refused, error “too many prefixes in this view”
Batch window server.ws_batch_ms, default 100 ms, 50 to 1,000 -
view_id 128 bytes SUBSCRIBE_REFUSED invalid view_id
A tag path 512 bytes The path comes back in refused

For the four keys, 0 (or no key) means the default; a value out of range stops the server at start with a message naming the key. The socket caps per session and per client address, and the send queue, are in Security and 21 CFR Part 11, WebSocket limits.

The runtime’s own client stays under these limits: it sends a long list in parts of at most 48 KiB with append, at most 10 messages a second (burst 16), and sends a message refused for rate again after a second.

Through eaxCloud remote access the browser’s messages are carried to the site within 64 KiB and 40 a second; the site applies the limits above again. Remote access closes a socket on a message over 16 MiB; the site’s 1 MiB frames keep a large answer under it.

The page’s client hmiBus takes a prefix entry (Plant/Line1/*) in the paths of hmiBus.subscribe(viewId, paths) and hmiBus.watch(paths, el); hmiBus.fetch takes exact paths only.

  • The tags a prefix gives are in hmiBus.tags and getAllTags() like any subscribed tag; hmiBus.tagsUnder('Plant/Line1/*') lists the cached ones under a prefix.
  • Each prefix summary of the server is dispatched as the event scada:tag-prefix (with the view_id) and kept in hmiBus.prefixInfo, keyed by the entry.
  • A tag the view holds only through a prefix is withdrawn, shown Bad “not subscribed”, never left with its last value as Good: when the last prefix covering it is released, when the server refuses the prefix, and after a reconnect when the server’s new answer no longer names it (no longer readable, or deleted).

A socket can stay open while nothing reaches it any more: a pulled cable, a connection a router or firewall forgot, a server stopped without closing its sockets. The socket’s close event never fires. Before 29 November the page’s client learnt that the link was down only from that event, so such a link read as live: no GATEWAY OFFLINE, no stale marking, live trends drawn as if their values were arriving.

The page’s client hmiBus now notes the arrival of every frame, of any type:

  • Timed out only after a heartbeat. Once the socket has received a HEARTBEAT, it may stay silent for 20 s (4 heartbeats), or for 4 × every_ms when the server’s interval is longer. A socket of a server that sends no heartbeat (an older server) is never timed out: a quiet link there is not taken for a dead one.
  • A reopened socket is timed out from its open. Once the page has seen a heartbeat on any socket, every later socket of the page gets the same limit as soon as it opens, before its first frame.
  • Checked twice. The client checks every 2 s. A socket silent past its limit on two checks in a row is down: a tab that was frozen or throttled gets its queued frames between the two checks. A silent link is therefore found 20 to 24 s after its last frame.
  • Handled as a close. The client lets go of the socket, closes it with code 4000 and the reason “no heartbeat”, and the link goes down as after a close: GATEWAY OFFLINE, every live value stale, the event scada:disconnected, and the reconnect with its usual backoff, every view subscribed again. The browser console says “No frame for n s: the link is taken as down, reconnecting”.
  • Down from the last frame. The scada:disconnected of a silent socket carries detail.since, the time of its last frame (milliseconds since 1970). A live trend’s “Live link down” span starts there, not at the detection 20 s later (When the live link goes down). A socket that closes gives no since: it is down from the close.

hmiBus.stats counts the heartbeats received (heartbeats) and the silent sockets dropped (silentDrops).

A socket can also open and then deliver nothing: a proxy or relay that accepts the upgrade and forwards nothing, such as the remote access relay over a dead link. Before 29 November, the page read the link up as soon as such a socket opened: GATEWAY OFFLINE went away, the event scada:connected was sent (the gauges’ link flag), and the views were subscribed again, while no value arrived. As the socket had no heartbeat of its own yet, it was not timed out either, and the link read online until the socket closed.

Now, once the page has seen a heartbeat:

  • The link reads up only at the reopened socket’s first frame, of any type (the server sends ALARM_INIT at once on every socket). Then, and not at the open: GATEWAY OFFLINE goes away, scada:connected is sent and every view is subscribed again. Until then the values stay stale.
  • The socket is timed out 20 s from its open (or 4 × every_ms), on the same two checks: a socket that delivers nothing is dropped 20 to 24 s after it opened, with code 4000. The link was already down, so no second scada:disconnected is sent.
  • The reconnect backoff starts over only when the link reads up. It is 1 s, growing by half at each try to at most 5 s. A socket that opens and delivers nothing no longer resets it, so the page keeps backing off instead of trying again every second.
  • A page’s first socket behaves as before: it reads the link up at its open, and is not timed out before its own heartbeat. The page may be served by an older server that sends no heartbeat.

With remote access from eaxCloud, the relay’s own side of this, which opens a remote page’s socket only once the site has accepted it, comes with the next eaxCloud release (eaxCloud: Changes).

The read right on each path is checked once, when it is subscribed; a tag a prefix gives is checked as an exact path, when the prefix is subscribed or, for a tag created later, when it is added. A change of the user’s rights closes the socket (within about 3 seconds); the browser reconnects and subscribes again under the new rights.