Skip to content

Data duplication on device reconnection – MQTT relay resends stale data #101

@Pranay265

Description

@Pranay265

Hello @PatrickRitchie

We’re using MTConnect.NET v6.6.0 and encountered data duplication behavior that seems unintended.

Reproduction Steps:

  • A printer is connected to the MTConnect agent via SHDR adapter.
  • Data flows correctly through the MQTT relay to our cloud system via greengrass gateway.
  • We disconnect the printer’s internet temporarily (simulate brief network loss).
  • Upon reconnection, we observe that the agent resends previously published data items through MQTT, even though those values haven’t changed.

What We Observed:

  • The MQTT relay publishes older/stale data again with the same timestamp and value.
  • This causes duplication in downstream systems (e.g., cloud database).
  • We verified this across multiple trials using a simulator and a real printer.
  • durable: true is set in the agent config, and the observationBufferSize is large enough.

Our Expectation:
The agent (or MQTT relay) should avoid republishing data that has already been sent unless there's an actual state or value change. We understand the rationale behind sending the last-known state, but in our case, this results in unnecessary duplicates.

assetBufferSize: 1000
convertUnits: true
defaultVersion: 2.1
devices: h350.xml
durable: true
enableMetrics: true
ignoreObservationCase: true
ignoreTimestamps: true
inputValidationLevel: Ignore
modules:
- mqtt-relay:
    allowUntrustedCertificates: true
    clientId: simulation
    currentInterval: 10000
    documentFormat: JSON
    port: 8883
    qos: 1
    sampleInterval: 500
    server: 10.81.130.137
    tls:
      omitCAValidation: true
      pem:
        certificateAuthority: GroupCACertificate.pem
        certificatePath: certificate.pem
        privateKeyPath: privateKey.pem
      verifyClientCertificate: false
    topicPrefix: MTConnect
    topicStructure: Entity
- shdr-adapter:
    deviceKey: H350
    hostname: localhost
    ignoreHeartbeatOnChange: false
    port: 7878
monitorConfigurationFiles: false
observationBufferSize: 150000

We would appreciate any insights into whether this is intended behavior or a potential bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions