How live values reach screens
The Studio and the operator runtime receive live tag values over one WebSocket per browser tab, /ws. The server sends each tab the values of the tags its open views show, and nothing else. This page explains how that works and what it means for operators, engineers and the size of a server. The messages themselves are in the live data socket reference.
Only the tags the open views show
Section titled “Only the tags the open views show”A view is anything on the page that shows tags: the page itself, a popup, a dock, a 3D or isometric view, a preview, a dialog, a data grid, the trend of the Trends workspace. Each view tells the server which tags it shows (it subscribes them). When the operator navigates, the page’s set is replaced; when a popup closes, its tags are released.
Most of this needs nothing from you. Before a page is drawn, the runtime reads the tags its screens name from their saved documents (the primary screen with its parameters, its default inner screen and the docks shown) and subscribes them, so their values are on the way while the screens are built. A popup does the same from its screen when it opens, and releases its tags when it closes. An inner screen that a script switches into a container (system.nav.swapInner, system.nav.loadInnerDisplay) does the same as the container’s own view, and releases its tags when the page is left or the container shows another screen. The tags a screen names include the Tags list of each web content object (on a screen saved before that list existed, the paths its HTML names literally). 3D and isometric screens and dashboards subscribe their own tags. Every binding, expression and object that reads a tag the documents did not name (a path built in an expression, for example) subscribes it the first time it reads it. After a page change, the tags nothing has read since are released a few seconds later. A grid of tags follows all its rows up to 5,000 rows and, above that, the rows on screen; a grid that is hidden follows nothing. The Trends workspace follows its visible pens while it is shown.
Before this release, every tab received every tag its user may read, the whole project, then one message per change of any of them. The cost grew with the size of the project and its change rate, not with what the operators look at. Now it grows with what is on the screens.
Read rights are checked when a tag is subscribed
Section titled “Read rights are checked when a tag is subscribed”The server checks the user’s read right on each tag when a view subscribes it. A tag the user may not read is refused and its value is never sent. A view may also subscribe a prefix such as Plant/Line1/*: every tag under it is checked the same way, as an exact path, also a tag created there later, and a tag the user may not read is only counted, never named or sent (Prefixes). When a user’s rights change (a role, group or permission edit), the server closes that user’s sockets within about 3 seconds; the browser reconnects and subscribes again, each tag checked against the new rights.
Changes are batched every 100 ms
Section titled “Changes are batched every 100 ms”The server collects the changes of a tab’s subscribed tags and sends them together every 100 ms (the batch window, server.ws_batch_ms). A batch holds the latest value of each tag that changed, each with its own quality and timestamp: a change to Bad is never folded into a Good value. A value can reach the screen up to about 100 ms later than before.
A tab that cannot keep up (a slow link, a busy computer) gets the latest values, not a growing backlog: at most two batches wait for it, and the next one holds the newest values. A tab that stops reading altogether is closed and reconnects, as before.
What the operator sees
Section titled “What the operator sees”- A new screen waits for its values. A page, dock, popup or inner screen drawn for the first time stays hidden, and cannot be operated, until the server has answered for the tags it reads, for at most 2 seconds. Then it is shown with its live values. A value still missing after 2 seconds is shown Bad “No value received”, never as the value the object was designed with. On a local network the wait is usually too short to notice; when the link is down the screen is shown at once, with its values stale. A dock and an inner screen wait for the tags of their own objects, the Tags lists of web content included, which are read outside the canvas.
- Everything on a held screen is held (17 November). The drawing and the screen’s HTML objects (gauges, bars, alarm lines, buttons, web content) are hidden together and take no tap, click, key or focus; so are an isometric map on a page, in a dock, a popup or an inner screen, whose blocks refuse every command (click, tap, momentary press, Enter or Space, the phone’s card) while it is held, and the phone’s cards beside a held screen. Both layers are shown again in the same frame. A small status line, centred in the screen’s place, says the values are loading. A held screen that is swapped, left or closed lets go at once, so the next screen there is not hidden. Before, only the drawing was hidden: the HTML objects showed default or stale values and could be pressed, and an isometric map could be clicked before its values arrived.
- A very large screen waits for all its values (17 November). The server sends the answer for many tags (a prefix of a whole plant area, for example) in parts of at most 1 MiB. The screen stays held while the parts keep coming, each within 2 seconds of the one before, for at most 30 seconds in all, and the status line says “Loading values… N% (n/m)” with the parts received. When the parts stop coming, or after 30 seconds, the screen is shown and the values still missing show Bad. Before, such a screen was shown after 2 seconds with Bad values that then turned good.
- A tag the user may not read is shown Bad “not readable for this account”, with no value. On screen objects it gets a blue lock instead of the red ✕, and the object is greyed out as for Bad. A gauge shows a dash, a padlock and NOT READABLE on its face instead. See A tag the account may not read.
- A tag the server does not know is shown Bad “unknown tag”, with no value. It stays subscribed: a tag created later appears when it first changes.
- Over the limit (50,000 tags for one tab by default,
server.ws_max_tags): the tags past it are shown Bad “too many tags on this page”, with no value. - A tag released (its view closed) is never left showing its last value as Good.
- When the link goes down, every live value is shown stale (the dashed outline) and GATEWAY OFFLINE shows. A socket that closes is seen at once. A socket that stays open while nothing reaches it (a pulled cable, a connection a router or firewall forgot) is found by the server’s heartbeat, sent every 5 s: 20 to 24 s after its last frame the page treats it as closed and reconnects (29 November; A link that goes silent). Before, such a link read as live.
- Live trends stop where the link went down and draw nothing across the outage: a grey band covers the span and a Live link down chip shows while it lasts. See When the live link goes down.
- After a reconnect, every view subscribes again, and values stay stale (the dashed outline) until the server’s answers are in. See Show bad and stale values.
A tag’s unit and description come with the server’s first answer for that tag. A unit or description changed while a page is open reaches the page the next time a view subscribes the tag, for example when the page is opened again or reloaded.
Screen scripts and widgets
Section titled “Screen scripts and widgets”system.tag.read of a tag no view shows subscribes it for the call and keeps it for 30 seconds; system.tag.subscribe holds its tag until it is unsubscribed. See Screen scripting API.
The page’s own tag cache holds only the subscribed tags. Code that listed every tag of the project from it (hmiBus.getAllTags(), the tag map of an HTML widget) now gets the subscribed tags only.
After an upgrade: reload open tabs
Section titled “After an upgrade: reload open tabs”A browser tab opened before the upgrade does not subscribe. It still receives alarms and system messages, but no tag values: its objects show their values as stale, never as good. Reload each such tab (operator consoles and wall screens included) after the upgrade. The server serves its pages with revalidation, so a reload always gets the new page.
Remote access
Section titled “Remote access”Through eaxCloud remote access the browser’s subscriptions are carried to the site’s /ws like the values in the other direction, with the same limits (messages of at most 64 KiB, and at most 40 a second through the relay; the site applies its own limit of 20 a second, see the reference). In the other direction the site sends no frame over 1 MiB: a large snapshot comes in parts and a large batch of changes in several frames (17 November), so a screen of a very large area no longer closes the remote session’s socket.
What a control room costs
Section titled “What a control room costs”The work on the server follows the changes of the tags on screen. A tag that no tab shows costs one lookup per change, and nothing is sent.
Measured on a project of 100,000 tags changing 10,000 times a second in total, with 20 browser tabs showing 300 tags each (a control room of 20 screens):
| Before (every tag to every tab) | Now (the tags on screen) | |
|---|---|---|
| Server CPU | 2.40 cores | 0.07 cores |
| Data sent to each tab | 2.08 MB/s | 2.8 kB/s |
A screen of 300 tags in such a project costs the server about 0.0035 cores. The project’s size matters much less than how many tags are on screen and how often they change.
Registering the tags at start-up also grows in step with their number: 100,000 tags register in well under a second (it took 11 to 14 minutes before), and the tag engine holds about 175 bytes per tag, measured with a unit and a description on every tag. Nothing changes in the API.
Settings
Section titled “Settings”Four keys in the server: section of config.yaml; the defaults suit most sites.
| Key | Default | Allowed | What it sets |
|---|---|---|---|
ws_batch_ms |
100 |
50 to 1000 (0: the default) | The batch window, in milliseconds. Shorter: values reach screens sooner, more messages. Longer: fewer messages, later values |
ws_max_tags |
50000 |
1 to 500,000 (0: the default) | Tags one tab may subscribe |
ws_max_views |
256 |
1 to 4,096 (0: the default) | Views one tab may subscribe for |
ws_max_prefixes |
16 |
1 to 256 (0: the default) | Prefix entries (Plant/Line1/*) one view may hold |
A value out of range stops the server at start with a message naming the key. See Server flags and configuration and the generated configuration reference.