0 Replies Latest reply on Jan 12, 2018 9:36 PM by tludvigsen RSS
    tludvigsen Newbie

    MQTT error on connection reset

    Hello Thingworx community!


    I'm using the MQTT extention on two Thingworx servers, one with version 7 and one with version 6.5.2-b463. I'm using the same MQTT extension (ThingWorx IoT Marketplace) connecting to the same MQTT broker, but on the version 6.5.2-b463 Thingworx server, the connection goes down after roughly 12 hours (44214 seconds).


    In Thingworx monitor I get two warnings:

    2017-05-23 06:20:46: Lost MQTT Connection For [SensationIIIDataConnection] : Exception Was Connection lost

    2017-05-23 06:20:46: Lost MQTT Connection For [SensationIIIDataConnection] : Cause Was Connection reset

    followed by two errors:

    2017-05-23 06:21:21: Unable to connect to MQTT in [SensationIIIDataConnection] : Timed out waiting for a response from the server

    2017-05-23 06:21:21: Unable to close client in MQTT Thing SensationIIIDataConnection : Connect already in progress


    On the broker's server, I find these relevant lines in the logs:

    Tue, 23 May 2017 06:21:00: Client SensationIIIDataConnection has exceeded timeout, disconnecting.

    Tue, 23 May 2017 06:21:00: Socket error on client SensationIIIDataConnection, disconnecting.

    followed by successful reconnect:

    Tue, 23 May 2017 06:21:28: New connection from <my server's ip> on port XXXX.

    Tue, 23 May 2017 06:21:28: New client connected from <my server's ip> as SensationIIIDataConnection (c1, k60, u'username').

    Tue, 23 May 2017 06:21:28: Sending CONNACK to SensationIIIDataConnection (0, 0)

    Tue, 23 May 2017 06:22:28: Received PINGREQ from SensationIIIDataConnection

    Tue, 23 May 2017 06:22:28: Sending PINGRESP to SensationIIIDataConnection

    ... follwed by PINGREQ -> PINGRESP every minute


    After the logged events, Thingworx 6.5.2-b463 and the broker have different perceptions of the connection status.

    Since there are no SUBSCRIBE or SUBACK messages after the CONNACK, the broker doesn't forward any data to the "new" SensationIIIDataConnection client. It does however regard is as connected and keeps its connection alive.


    The MQTT thing SensationIIIDataConnection in Thingworx version 6.5.2-b463 has property isConnected set to false even if pings are running in the background. No data is coming in. To be able to reconnect the thing, I have to change the clientIdFormat first. Otherwise I get the error:

    Unable to connect to MQTT in [SensationIIIDataConnection] : Persistence already in use


    After a similar event on the Thingworx version 7-server, connection is re-established, including SUBSCRIBE and SUBACK, and data transfer continues normally.


    What causes the connection lost/connection reset on the Thingworx 6.5.2-b463 side?

    Why does the thing not reconnect successfully?

    How can I work around it?


    Best regards