Skip to content

Gateway: Prevent data-sharing rate limits from blocking cloud-initiated agent-linked attribute write confirmations #2832

In progress

Description

@pierrekil

Problem

When using Manager Interconnect, it is possible to limit how frequently a gateway sends attribute value updates to the central manager (e.g. once per minute) to reduce unnecessary data traffic.

However, we observed that enabling this rate limit also affected attribute writes initiated from the central manager.

Specifically, this occurred when changing asset attributes with a Modbus agent link. Although the commands were forwarded to the gateway, the resulting attribute value updates were not always propagated back to the central manager immediately. Consequently, the attributes on the central manager were not updated as expected, and the changes appeared to fail.

We worked around this by using the following custom data-sharing filter configuration:

[
  {
    "valueChange": true,
    "durationParsedMillis": null
  }
]

This allowed attribute value changes to propagate without the configured delay. However, this is not ideal because regular attribute value changes also bypass the intended rate limit.

Expected behavior

Data-sharing rate limits should only affect regular gateway-originated attribute value updates, not the results of attribute writes initiated from the central manager.

In particular:

  • Attribute writes initiated from the central manager should be forwarded to the gateway immediately.
  • The resulting attribute value updates should be propagated back to the central manager as soon as they are available, regardless of the configured rate limit.
  • Successful writes should not appear to fail because their resulting attribute updates are filtered.
  • Actual write failures should still be handled correctly.
  • Regular gateway-originated attribute value updates should continue to respect the configured rate limits.

This should allow users to reduce gateway-to-cloud data traffic without compromising control of gateway assets.

Technical analysis

Attribute filtering

The existing GatewayClientConnector.getOutboundAttributeEventFilter() already contains logic intended to bypass filtering for attribute events originating from the central manager:

// Allow attribute events that came from the central manager to be returned
if (getClass().getSimpleName().equals(ev.getSource())) {
  return ev;
}

Incoming cloud-initiated writes are processed with GatewayClientConnector as their event source.

However, when an attribute has an agent link, AgentService intercepts the write and forwards it to the corresponding protocol. The protocol subsequently generates a separate attribute event representing the resulting value.

For Modbus, AbstractModbusProtocol handles successful writes by either:

  • Publishing an attribute update for write-only attributes.
  • Triggering an immediate verification read for attributes that also have a read address.

These subsequent attribute updates originate from AgentService rather than GatewayClientConnector. As a result, the existing source-based bypass no longer applies, and the events can be suppressed by the configured data-sharing rate limit.

Additionally, the duration filter drops events that occur within the configured interval rather than queueing them for later delivery. Therefore, an update may never reach the central manager unless another qualifying update is generated.

Attribute write timeout

The Manager UI uses a default timeout of 5 seconds when writing attribute values. After sending a write request, it waits for an updated attribute event to be received. If no update arrives within this timeout, the UI indicates that the write failed.

With a one-minute data-sharing rate limit, the resulting Modbus attribute update may be filtered, causing the UI to display a failure even though the command was successfully executed by the gateway.

Simply increasing the UI timeout would not properly address this issue because filtered attribute events are dropped rather than delayed.

Possible solutions

Option 1: Track pending cloud-initiated attribute writes

When receiving an attribute write from the central manager, the gateway could temporarily track the pending write.

The outbound attribute filter could then allow the corresponding resulting attribute update to bypass the configured rate limit.

This could be implemented generically in GatewayClientConnector, without requiring changes to individual agent protocols.

Pending writes could be tracked by attribute reference, allowing the first subsequent attribute update for that attribute to bypass the configured rate limit. Entries would be removed after the update is forwarded or when a timeout expires.

Advantages:

  • Relatively small change, primarily within the gateway implementation.
  • No changes to existing data-sharing configuration.
  • Regular attribute value updates remain rate-limited.
  • Potentially applicable to all agent protocols using the standard attribute processing pipeline.
  • No protocol-specific changes would be necessary.

Disadvantages:

  • Requires tracking pending writes and cleaning up expired entries.
  • Concurrent writes to the same attribute need careful handling.
  • An unrelated attribute update could be incorrectly identified as the result of a pending write.
  • Matching updates by attribute reference or value alone does not guarantee that an update represents a successful command.
  • Agents that do not publish a resulting attribute update would not benefit from this mechanism.

This approach would solve the filtering problem for many agent protocols, but it would not provide definitive confirmation that a command was successfully executed.

Option 2: Explicitly identify and propagate command results

Introduce a mechanism to correlate cloud-initiated attribute writes with their resulting updates or execution results.

These command-related events could bypass normal data-sharing filters independently of regular attribute value synchronization.

Advantages:

  • More robust distinction between command results and regular attribute updates.
  • Supports explicit success/failure reporting.
  • Avoids relying on event source or timing to identify command-related updates.
  • Can distinguish command acceptance from verified device state.
  • Can provide a general solution for different agent protocols.

Disadvantages:

  • More complex implementation.
  • May require changes to event handling, protocol APIs, and Manager Interconnect communication.
  • Must account for protocols that execute commands asynchronously or cannot verify the resulting device state.
  • Backward compatibility between gateway and central manager versions needs consideration.

Option 3: Exclude controllable attributes from rate limiting

Allow users to configure data-sharing filters so that writable or otherwise selected attributes are not rate-limited.

Advantages:

  • Uses the existing filtering mechanism.
  • Relatively straightforward to configure.
  • No changes to command processing are necessary.

Disadvantages:

  • Requires users to identify and configure affected attributes.
  • All updates for excluded attributes bypass the rate limit, including regular attribute value changes.
  • Does not solve the underlying issue automatically.

Suggested approach

Option 1 seems like a reasonable starting point because it could address the issue with limited changes while preserving existing Manager Interconnect behavior.

By implementing pending-write tracking in GatewayClientConnector, this approach could work generically across agent protocols without modifying their implementations.

However, the implementation must account for concurrent writes, pending-write expiration, and unrelated attribute updates. Since subsequent updates are not explicitly correlated with their originating writes, they should not automatically be interpreted as definitive confirmation of successful execution.

If reliable correlation cannot be achieved without significant complexity, Option 2 would provide a cleaner long-term solution.

Ideally, the implementation should remain generic rather than introducing special handling for Modbus.

Acceptance criteria

  • Cloud-initiated attribute writes with Modbus agent links work correctly when a one-minute data-sharing rate limit is configured.
  • Resulting attribute updates bypass the data-sharing rate limit and are forwarded as soon as available.
  • Both write-only and read/write Modbus attributes are supported.
  • Successful operations that complete within the normal UI timeout no longer incorrectly display a failure.
  • Unrelated gateway-originated attribute value updates continue to respect configured rate limits.
  • Failed or unconfirmed writes are not incorrectly reported as successful.
  • Concurrent writes and pending-write expiration are handled safely.
  • Integration tests cover cloud-initiated writes with data-sharing filters enabled.

Activity

  1. added
    Gateways
    on Aug 26, 2026
  2. changed the title [-]Gateway: not filter attribute events sent from a gateway when the write originates from the central instance[/-] [+]Gateway: Prevent data-sharing rate limits from blocking cloud-initiated agent-linked attribute write confirmations[/+] on Nov 3, 2026
  3. richturner commented on Nov 5, 2026

    @richturner
    Member

    I agree option 1 seems the best option here, could use a google Cache to self evict incoming AttributeRefs after a timeout.

    Could also limit this functionality to events with certain sources (AgentService, etc.).

    The description raises an interesting point about duration filters essentially failing to report attribute events after the duration has passed, this should be raised as its' own issue.

  4. richturner commented on Nov 5, 2026

    @richturner
    Member

    Longer term we need a better way of tracking attribute writes and their result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Gateways

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions