Skip to content

The broker quit operation - "Keep alive time overdue". #35

Open

Description

@ingoogni

The broker quit operation after a client disconnects. It happened a few times, but it is not something I can reproduce. Below is all I could catch.

Using nmqtt-1.0.4, Nim 1.6.6, Windows 11

rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
tx> ConnAck(00): 00 02
Connections >> shellyplug-s-BCFF4D5A2607 was disconnected. Keep alive time overdue.
Client      >> shellyplug-s-BCFF4D5A2607
  host:
  sslOn: false
  sslCert:
  sslKey:
  verbosity: 0
  beenConnected: true
  username:
  password:
  clientId: shellyplug-s-BCFF4D5A2607
  s: ..disconnected..
  msgIdSeq: 3
  workQueue: 0
  pubCallbacks: 0
  inWork: false
  keepAlive: 60
  willFlag: false
  willQoS: 0
  willRetain: false
  willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
  willMsg: false
  proto: MQTT
  version: 4
  connFlags: 00000110
  subscribed: 3

PS C:\Users\xxx>```

Activity

  1. ingoogni commented on Sep 27, 2022

    @ingoogni
    Author

    In an attempt to isolate the problem I set up a separate system for one device measuring, a broker and a client only listening. After some time I intentionally reboot the device. After that it does not seem to (re)connect, I do not know the cause for that. But I do not expect the broker to quit because of that.

    The broker:

    PS > nmqtt -h 192.168.1.11 -p 1884 -v 3
    Running nmqtt v1.0.4
    
    BROKER:
      Host:       192.168.1.11
      Port:       1884
      SSL:        false
      Starting:   2022-09-27T12:04:51+02:00
    
    OPTIONS:
      Verbosity:             3
      Max connections:       0
      ClientID max lenght:   60
      ClientID allow spaces: false
      ClientID allow empty:  false
      ClientID in payload:   false
      Client kick old:       false
      Number of passwords:   0
    
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    Connections >> shellyplug-s-BCFF4D5A2607 has connected
    Client      >> shellyplug-s-BCFF4D5A2607
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shellyplug-s-BCFF4D5A2607
      s: ..connected..
      msgIdSeq: 0
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 0
    
    tx> ConnAck(00): 00 00
    rx> Subscribe(02): 00 15 00 10 73 68 65 6C 6C 69 65 73 2F 63 6F 6D 6D 61 6E 64 00
    Client      >> shellyplug-s-BCFF4D5A2607 has subscribed to a topic
    Subscribers >> {shellies/command: 1}
    tx> SubAck(02): 00 15
    rx> Subscribe(02): 00 16 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 63 6F 6D 6D 61 6E 64 00
    Client      >> shellyplug-s-BCFF4D5A2607 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/command: 1}
    tx> SubAck(02): 00 16
    rx> Subscribe(02): 00 17 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 63 6F 6D 6D 61 6E 64 00
    Client      >> shellyplug-s-BCFF4D5A2607 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}
    tx> SubAck(02): 00 17
    rx> Publish(00): 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 74 72 75 65
    2022-09-27T10:04:51.654 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 11 73 68 65 6C 6C 69 65 73 2F 61 6E 6E 6F 75 6E 63 65 7B 22 69 64 22 3A 22 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 6D 6F 64 65 6C 22 3A 22 53 48 50 4C 47 2D 53 22 2C 22 6D 61 63 22 3A 22 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 69 70 22 3A 22 31 39 32 2E 31 36 38 2E 31 2E 32 30 30 22 2C 22 6E 65 77 5F 66 77 22 3A 66 61 6C 73 65 2C 22 66 77 5F 76 65 72 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 7D
    2022-09-27T10:04:51.654 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2B 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 61 6E 6E 6F 75 6E 63 65 7B 22 69 64 22 3A 22 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 6D 6F 64 65 6C 22 3A 22 53 48 50 4C 47 2D 53 22 2C 22 6D 61 63 22 3A 22 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 69 70 22 3A 22 31 39 32 2E 31 36 38 2E 31 2E 32 30 30 22 2C 22 6E 65 77 5F 66 77 22 3A 66 61 6C 73 65 2C 22 66 77 5F 76 65 72 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 7D
    2022-09-27T10:04:51.669 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 27 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 69 6E 66 6F 7B 22 77 69 66 69 5F 73 74 61 22 3A 7B 22 63 6F 6E 6E 65 63 74 65 64 22 3A 74 72 75 65 2C 22 73 73 69 64 22 3A 22 69 6A 6E 65 74 67 6C 61 73 22 2C 22 69 70 22 3A 22 31 39 32 2E 31 36 38 2E 31 2E 32 30 30 22 2C 22 72 73 73 69 22 3A 2D 35 36 7D 2C 22 63 6C 6F 75 64 22 3A 7B 22 65 6E 61 62 6C 65 64 22 3A 66 61 6C 73 65 2C 22 63 6F 6E 6E 65 63 74 65 64 22 3A 66 61 6C 73 65 7D 2C 22 6D 71 74 74 22 3A 7B 22 63 6F 6E 6E 65 63 74 65 64 22 3A 74 72 75 65 7D 2C 22 74 69 6D 65 22 3A 22 31 32 3A 30 34 22 2C 22 75 6E 69 78 74 69 6D 65 22 3A 31 36 36 34 32 37 33 30 39 32 2C 22 73 65 72 69 61 6C 22 3A 35 2C 22 68 61 73 5F 75 70 64 61 74 65 22 3A 66 61 6C 73 65 2C 22 6D 61 63 22 3A 22 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 63 66 67 5F 63 68 61 6E 67 65 64 5F 63 6E 74 22 3A 31 2C 22 61 63 74 69 6F 6E 73 5F 73 74 61 74 73 22 3A 7B 22 73 6B 69 70 70 65 64 22 3A 30 7D 2C 22 72 65 6C 61 79 73 22 3A 5B 7B 22 69 73 6F 6E 22 3A 74 72 75 65 2C 22 68 61 73 5F 74 69 6D 65 72 22 3A 66 61 6C 73 65 2C 22 74 69 6D 65 72 5F 73 74 61 72 74 65 64 22 3A 30 2C 22 74 69 6D 65 72 5F 64 75 72 61 74 69 6F 6E 22 3A 30 2C 22 74 69 6D 65 72 5F 72 65 6D 61 69 6E 69 6E 67 22 3A 30 2C 22 6F 76 65 72 70 6F 77 65 72 22 3A 66 61 6C 73 65 2C 22 73 6F 75 72 63 65 22 3A 22 68 74 74 70 22 7D 5D 2C 22 6D 65 74 65 72 73 22 3A 5B 7B 22 70 6F 77 65 72 22 3A 30 2E 30 30 2C 22 6F 76 65 72 70 6F 77 65 72 22 3A 30 2E 30 30 2C 22 69 73 5F 76 61 6C 69 64 22 3A 74 72 75 65 2C 22 74 69 6D 65 73 74 61 6D 70 22 3A 31 36 36 34 32 38 30 32 39 32 2C 22 63 6F 75 6E 74 65 72 73 22 3A 5B 30 2E 30 30 30 2C 20 30 2E 30 30 30 2C 20 30 2E 30 30 30 5D 2C 22 74 6F 74 61 6C 22 3A 30 7D 5D 2C 22 74 65 6D 70 65 72 61 74 75 72 65 22 3A 32 33 2E 38 38 2C 22 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 22 3A 66 61 6C 73 65 2C 22 74 6D 70 22 3A 7B 22 74 43 22 3A 32 33 2E 38 38 2C 22 74 46 22 3A 37 34 2E 39 38 2C 20 22 69 73 5F 76 61 6C 69 64 22 3A 74 72 75 65 7D 2C 22 75 70 64 61 74 65 22 3A 7B 22 73 74 61 74 75 73 22 3A 22 69 64 6C 65 22 2C 22 68 61 73 5F 75 70 64 61 74 65 22 3A 66 61 6C 73 65 2C 22 6E 65 77 5F 76 65 72 73 69 6F 6E 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 2C 22 6F 6C 64 5F 76 65 72 73 69 6F 6E 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 7D 2C 22 72 61 6D 5F 74 6F 74 61 6C 22 3A 35 32 30 37 32 2C 22 72 61 6D 5F 66 72 65 65 22 3A 33 39 37 35 32 2C 22 66 73 5F 73 69 7A 65 22 3A 32 33 33 36 38 31 2C 22 66 73 5F 66 72 65 65 22 3A 31 36 36 36 36 34 2C 22 75 70 74 69 6D 65 22 3A 34 38 36 7D
    2022-09-27T10:04:51.685 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    2022-09-27T10:04:51.701 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-27T10:04:51.705 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-27T10:04:51.705 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 33 2E 38 38
    2022-09-27T10:04:51.705 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 37 34 2E 39 38
    2022-09-27T10:04:51.705 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-27T10:04:51.705 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Connect(00): 00 04 4D 51 54 54 04 02 00 3C 00 0D 6E 6D 71 74 74 73 75 62 2D 37 36 39 32
    Connections >> nmqttsub-7692 has connected
    Client      >> nmqttsub-7692
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: nmqttsub-7692
      s: ..connected..
      msgIdSeq: 0
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic:
      willMsg:
      proto: MQTT
      version: 4
      connFlags: 00000010
      subscribed: 0
    
    tx> ConnAck(00): 00 00
    rx> Subscribe(02): 00 09 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 02
    Client      >> nmqttsub-7692 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}
    tx> SubAck(02): 00 09
    rx> Subscribe(02): 00 07 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 02
    Client      >> nmqttsub-7692 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}
    tx> SubAck(02): 00 07
    rx> Subscribe(02): 00 0B 00 3A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 6F 76 65 72 70 6F 77 65 72 5F 76 61 6C 75 65 02
    Client      >> nmqttsub-7692 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}
    tx> SubAck(02): 00 0B
    rx> Subscribe(02): 00 0A 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 02
    Client      >> nmqttsub-7692 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}
    tx> SubAck(02): 00 0A
    rx> Subscribe(02): 00 0C 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 02
    Client      >> nmqttsub-7692 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 1}
    tx> SubAck(02): 00 0C
    rx> Subscribe(02): 00 08 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 02
    Client      >> nmqttsub-7692 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 1}
    tx> SubAck(02): 00 08
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-27T10:05:18.909 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    2022-09-27T10:05:21.647 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-27T10:05:21.647 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-27T10:05:21.662 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 34 2E 31 30
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 34 2E 31 30
    2022-09-27T10:05:21.662 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 37 35 2E 33 39
    2022-09-27T10:05:21.662 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-27T10:05:21.662 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    2022-09-27T10:05:51.643 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-27T10:05:51.643 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-27T10:05:51.659 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 34 2E 30 33
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 34 2E 30 33
    2022-09-27T10:05:51.659 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 37 35 2E 32 35
    2022-09-27T10:05:51.659 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-27T10:05:51.668 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-27T10:06:01.511 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    2022-09-27T10:06:21.642 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-27T10:06:21.658 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-27T10:06:21.658 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 33 2E 37 37
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 33 2E 37 37
    2022-09-27T10:06:21.658 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 37 34 2E 37 38
    2022-09-27T10:06:21.674 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-27T10:06:21.674 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    --- Reboot the Shelly device at this point ---
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> PingReq(00):
    tx> PingResp(00):
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> PingReq(00):
    tx> PingResp(00):
    rx> PingReq(00):
    tx> PingResp(00):
    Connections >> shellyplug-s-BCFF4D5A2607 was disconnected. Keep alive time overdue.
    Client      >> shellyplug-s-BCFF4D5A2607
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shellyplug-s-BCFF4D5A2607
      s: ..disconnected..
      msgIdSeq: 23
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 3
    

    A client just listening to the broker fwiw:

    [...]
    Connecting to 192.168.1.11:1884
    tx> Connect(00): 00 04 4D 51 54 54 04 02 00 3C 00 0D 6E 6D 71 74 74 73 75 62 2D 37 36 39 32
    rx> ConnAck(00): 00 00
    Connection established
    tx> Subscribe(02): 00 09 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 02
    tx> Subscribe(02): 00 07 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 02
    tx> Subscribe(02): 00 0B 00 3A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 6F 76 65 72 70 6F 77 65 72 5F 76 61 6C 75 65 02
    tx> Subscribe(02): 00 0A 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 02
    tx> Subscribe(02): 00 0C 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 02
    tx> Subscribe(02): 00 08 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 02
    rx> SubAck(02): 00 09
    rx> SubAck(02): 00 07
    rx> SubAck(02): 00 0B
    rx> SubAck(02): 00 0A
    rx> SubAck(02): 00 0C
    rx> SubAck(02): 00 08
    tx> PingReq(00):
    rx> PingResp(00):
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 0
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 0.00
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 0
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 34 2E 31 30
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 24.10
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 0.00
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 0
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 34 2E 30 33
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 24.03
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    tx> PingReq(00):
    rx> PingResp(00):
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 0
    tx> PingReq(00):
    rx> PingResp(00):
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 0.00
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 0
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 33 2E 37 37
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 23.77
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    tx> PingReq(00):
    rx> PingResp(00):
    tx> PingReq(00):
    rx> PingResp(00):
    tx> PingReq(00):
    rx> PingResp(00):
    tx> PingReq(00):
    rx> PingResp(00):
    tx> PingReq(00):
    rx> PingResp(00):
    tx> PingReq(00):
    rx> PingResp(00):
    Closing: remote closed connection
    tx> Disconnect(00):
    Connecting to 192.168.1.11:1884
    Error connecting to 192.168.1.11
    The remote computer refused the network connection.
    
    Connecting to 192.168.1.11:1884
    Error connecting to 192.168.1.11
    The remote computer refused the network connection.
    
    Connecting to 192.168.1.11:1884
    Error connecting to 192.168.1.11
    The remote computer refused the network connection.
    
    
  2. ThomasTJdev commented on Sep 28, 2022

    @ThomasTJdev
    Collaborator

    Hi @ingoogni

    Thanks for reporting it - it sounds strange. I have tested the setup without any problems:

    # Broker
    nmqtt -h 127.0.0.1 -p 1884 -v 3
    # Client 1
    nmqtt_sub -h 127.0.0.1 -p 1884 -v3 --topic igno
    # Client 2
    nmqtt_sub -h 127.0.0.1 -p 1884 -v3 --topic igno
    # Client 3
    nmqtt_sub -h 127.0.0.1 -p 1884 -v3 --topic igno
    # Pub 1
    nmqtt_pub -h 127.0.0.1 -p 1884 -v3 --topic igno --msg hej
    
    # Scenario 1
    1) Disconnect client 1
    2) Connect client 1
    3) Check published msg is received
    4) Repeat with other clients
    
    # Scenario 2
    1) Disconnect (close) broker
    2) Clients gives errors
    3) Startup broker
    4) Clients auto-connect to broker
    5) Check published msg is received
    
    # Scenario 3
    1) Perform scenario 1 and 2 multiple times
    2) Ensure everything works
    

    When the broker disconnects, the clients will try to auto-reconnect like this:

    Closing: remote closed connection # <= Broker was closed / stopped
    tx> Disconnect(00): 
    Connecting to 127.0.0.1:1884
    Error connecting to 127.0.0.1
    Connection refused
    Connecting to 127.0.0.1:1884
    Error connecting to 127.0.0.1
    Connection refused
    Connecting to 127.0.0.1:1884
    Error connecting to 127.0.0.1
    Connection refused
    Connecting to 127.0.0.1:1884
    Error connecting to 127.0.0.1
    Connection refused
    Connecting to 127.0.0.1:1884
    Error connecting to 127.0.0.1
    Connection refused
    Connecting to 127.0.0.1:1884 # <= Broker was started
    tx> Connect(00): 00 04 4D 51 54 54 04 02 00 3C 00 0F 6E 6D 71 74 74 73 75 62 2D 31 31 34 30 35 31 
    rx> ConnAck(00): 00 00 
    Connection established
    tx> Subscribe(02): 00 02 00 04 69 67 6E 6F 00 
    rx> SubAck(02): 00 02 
    
  3. ingoogni commented on Sep 28, 2022

    @ingoogni
    Author

    Thanks for looking in to it.

    When I simulate it like you do, I get the same results as you do.

    The problem that occurs with the rebooting of the Shelly device is reproducible.

    The Shelly device is a commercial one, build on an ESP8266 with Mongoose OS. That's all the info I have on that.

    It will take some time, I can try the device with an other broker if that helps.

  4. ThomasTJdev commented on Sep 28, 2022

    @ThomasTJdev
    Collaborator

    Ohh, I see. Your error message is also The remote computer refused the network connection, that makes me think it's an OS/device error instead of a nmqtt error which just is Connection refused. Could it be some kind of user-restriction, requirement of manual activation, etc. on the device? I have no experience with Shelly devices, so I can't guide you on that one. Also you might want to give the keep alive time a look.

  5. ingoogni commented on Sep 28, 2022

    @ingoogni
    Author
    rx> PingResp(00):
    Closing: remote closed connection
    tx> Disconnect(00):
    Connecting to 192.168.1.11:1884
    Error connecting to 192.168.1.11
    The remote computer refused the network connection.
    

    That is the nmqtt subscriber client. It does that when the broker is not online. Once the broker is on line again it connects fine.

    There is something I have not tried. It is a plug so I can just pull it from its socket, wait and see what happens.

  6. ingoogni commented on Sep 28, 2022

    @ingoogni
    Author

    Pulling the whole device from the power socket so it stops sending data has the same result. After some time the broker quits.

    Another situation works fine. I start the broker and sub_client. After that I put the device in the socket. It connects fine and sends the data as to be expected.

    Broker log of pulling the plug:

    > nmqtt -h 192.168.1.11 -p 1884 -v 3
    Running nmqtt v1.0.4
    
    BROKER:
      Host:       192.168.1.11
      Port:       1884
      SSL:        false
      Starting:   2022-09-28T10:47:07+02:00
    
    OPTIONS:
      Verbosity:             3
      Max connections:       0
      ClientID max lenght:   60
      ClientID allow spaces: false
      ClientID allow empty:  false
      ClientID in payload:   false
      Client kick old:       false
      Number of passwords:   0
    
    
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    Connections >> shellyplug-s-BCFF4D5A2607 has connected
    Client      >> shellyplug-s-BCFF4D5A2607
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shellyplug-s-BCFF4D5A2607
      s: ..connected..
      msgIdSeq: 0
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 0
    
    tx> ConnAck(00): 00 00
    rx> Subscribe(02): 00 01 00 10 73 68 65 6C 6C 69 65 73 2F 63 6F 6D 6D 61 6E 64 00
    Client      >> shellyplug-s-BCFF4D5A2607 has subscribed to a topic
    Subscribers >> {shellies/command: 1}
    tx> SubAck(02): 00 01
    rx> Subscribe(02): 00 02 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 63 6F 6D 6D 61 6E 64 00
    Client      >> shellyplug-s-BCFF4D5A2607 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/command: 1}
    tx> SubAck(02): 00 02
    rx> Subscribe(02): 00 03 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 63 6F 6D 6D 61 6E 64 00
    Client      >> shellyplug-s-BCFF4D5A2607 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}
    tx> SubAck(02): 00 03
    rx> Publish(00): 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 74 72 75 65
    2022-09-28T08:47:08.332 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 11 73 68 65 6C 6C 69 65 73 2F 61 6E 6E 6F 75 6E 63 65 7B 22 69 64 22 3A 22 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 6D 6F 64 65 6C 22 3A 22 53 48 50 4C 47 2D 53 22 2C 22 6D 61 63 22 3A 22 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 69 70 22 3A 22 31 39 32 2E 31 36 38 2E 31 2E 32 30 30 22 2C 22 6E 65 77 5F 66 77 22 3A 66 61 6C 73 65 2C 22 66 77 5F 76 65 72 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 7D
    2022-09-28T08:47:08.348 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2B 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 61 6E 6E 6F 75 6E 63 65 7B 22 69 64 22 3A 22 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 6D 6F 64 65 6C 22 3A 22 53 48 50 4C 47 2D 53 22 2C 22 6D 61 63 22 3A 22 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 69 70 22 3A 22 31 39 32 2E 31 36 38 2E 31 2E 32 30 30 22 2C 22 6E 65 77 5F 66 77 22 3A 66 61 6C 73 65 2C 22 66 77 5F 76 65 72 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 7D
    2022-09-28T08:47:08.348 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 27 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 69 6E 66 6F 7B 22 77 69 66 69 5F 73 74 61 22 3A 7B 22 63 6F 6E 6E 65 63 74 65 64 22 3A 74 72 75 65 2C 22 73 73 69 64 22 3A 22 69 6A 6E 65 74 67 6C 61 73 22 2C 22 69 70 22 3A 22 31 39 32 2E 31 36 38 2E 31 2E 32 30 30 22 2C 22 72 73 73 69 22 3A 2D 35 33 7D 2C 22 63 6C 6F 75 64 22 3A 7B 22 65 6E 61 62 6C 65 64 22 3A 66 61 6C 73 65 2C 22 63 6F 6E 6E 65 63 74 65 64 22 3A 66 61 6C 73 65 7D 2C 22 6D 71 74 74 22 3A 7B 22 63 6F 6E 6E 65 63 74 65 64 22 3A 74 72 75 65 7D 2C 22 74 69 6D 65 22 3A 22 31 30 3A 34 37 22 2C 22 75 6E 69 78 74 69 6D 65 22 3A 31 36 36 34 33 35 34 38 32 39 2C 22 73 65 72 69 61 6C 22 3A 32 2C 22 68 61 73 5F 75 70 64 61 74 65 22 3A 66 61 6C 73 65 2C 22 6D 61 63 22 3A 22 42 43 46 46 34 44 35 41 32 36 30 37 22 2C 22 63 66 67 5F 63 68 61 6E 67 65 64 5F 63 6E 74 22 3A 30 2C 22 61 63 74 69 6F 6E 73 5F 73 74 61 74 73 22 3A 7B 22 73 6B 69 70 70 65 64 22 3A 30 7D 2C 22 72 65 6C 61 79 73 22 3A 5B 7B 22 69 73 6F 6E 22 3A 74 72 75 65 2C 22 68 61 73 5F 74 69 6D 65 72 22 3A 66 61 6C 73 65 2C 22 74 69 6D 65 72 5F 73 74 61 72 74 65 64 22 3A 30 2C 22 74 69 6D 65 72 5F 64 75 72 61 74 69 6F 6E 22 3A 30 2C 22 74 69 6D 65 72 5F 72 65 6D 61 69 6E 69 6E 67 22 3A 30 2C 22 6F 76 65 72 70 6F 77 65 72 22 3A 66 61 6C 73 65 2C 22 73 6F 75 72 63 65 22 3A 22 69 6E 70 75 74 22 7D 5D 2C 22 6D 65 74 65 72 73 22 3A 5B 7B 22 70 6F 77 65 72 22 3A 30 2E 30 30 2C 22 6F 76 65 72 70 6F 77 65 72 22 3A 30 2E 30 30 2C 22 69 73 5F 76 61 6C 69 64 22 3A 74 72 75 65 2C 22 74 69 6D 65 73 74 61 6D 70 22 3A 31 36 36 34 33 36 32 30 32 39 2C 22 63 6F 75 6E 74 65 72 73 22 3A 5B 30 2E 30 30 30 2C 20 30 2E 30 30 30 2C 20 30 2E 30 30 30 5D 2C 22 74 6F 74 61 6C 22 3A 30 7D 5D 2C 22 74 65 6D 70 65 72 61 74 75 72 65 22 3A 31 39 2E 35 39 2C 22 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 22 3A 66 61 6C 73 65 2C 22 74 6D 70 22 3A 7B 22 74 43 22 3A 31 39 2E 35 39 2C 22 74 46 22 3A 36 37 2E 32 37 2C 20 22 69 73 5F 76 61 6C 69 64 22 3A 74 72 75 65 7D 2C 22 75 70 64 61 74 65 22 3A 7B 22 73 74 61 74 75 73 22 3A 22 69 64 6C 65 22 2C 22 68 61 73 5F 75 70 64 61 74 65 22 3A 66 61 6C 73 65 2C 22 6E 65 77 5F 76 65 72 73 69 6F 6E 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 2C 22 6F 6C 64 5F 76 65 72 73 69 6F 6E 22 3A 22 32 30 32 32 30 38 30 39 2D 31 32 34 35 30 36 2F 76 31 2E 31 32 2D 67 39 39 66 37 65 30 62 22 7D 2C 22 72 61 6D 5F 74 6F 74 61 6C 22 3A 35 32 30 37 32 2C 22 72 61 6D 5F 66 72 65 65 22 3A 33 39 33 36 34 2C 22 66 73 5F 73 69 7A 65 22 3A 32 33 33 36 38 31 2C 22 66 73 5F 66 72 65 65 22 3A 31 36 36 36 36 34 2C 22 75 70 74 69 6D 65 22 3A 32 30 7D
    2022-09-28T08:47:08.380 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    2022-09-28T08:47:08.380 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-28T08:47:08.380 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-28T08:47:08.395 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 35 39
    2022-09-28T08:47:08.395 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 36 37 2E 32 37
    2022-09-28T08:47:08.395 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-28T08:47:08.395 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-28T08:47:09.260 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Connect(00): 00 04 4D 51 54 54 04 02 00 3C 00 0D 6E 6D 71 74 74 73 75 62 2D 31 32 35 36
    Connections >> nmqttsub-1256 has connected
    Client      >> nmqttsub-1256
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: nmqttsub-1256
      s: ..connected..
      msgIdSeq: 0
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic:
      willMsg:
      proto: MQTT
      version: 4
      connFlags: 00000010
      subscribed: 0
    
    tx> ConnAck(00): 00 00
    rx> Subscribe(02): 00 04 00 3A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 6F 76 65 72 70 6F 77 65 72 5F 76 61 6C 75 65 02
    Client      >> nmqttsub-1256 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}
    tx> SubAck(02): 00 04
    rx> Subscribe(02): 00 05 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 02
    Client      >> nmqttsub-1256 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}
    tx> SubAck(02): 00 05
    rx> Subscribe(02): 00 03 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 02
    Client      >> nmqttsub-1256 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}
    tx> SubAck(02): 00 03
    rx> Subscribe(02): 00 02 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 02
    Client      >> nmqttsub-1256 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 1}
    tx> SubAck(02): 00 02
    rx> Subscribe(02): 00 06 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 02
    Client      >> nmqttsub-1256 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 1}
    tx> SubAck(02): 00 06
    rx> Subscribe(02): 00 01 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 02
    Client      >> nmqttsub-1256 has subscribed to a topic
    Subscribers >> {shellies/shellyplug-s-BCFF4D5A2607/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/temperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0: 1}, {shellies/command: 1}, {shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value: 1}, {shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 1}
    tx> SubAck(02): 00 01
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    2022-09-28T08:47:38.334 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-28T08:47:38.341 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-28T08:47:38.341 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 30 2E 30 35
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 30 2E 30 35
    2022-09-28T08:47:38.341 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 36 38 2E 30 38
    2022-09-28T08:47:38.341 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-28T08:47:38.357 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 32 34
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 32 34
    2022-09-28T08:47:40.560 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    2022-09-28T08:47:40.560 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 34 39 2E 39 38
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 34 39 2E 39 38
    2022-09-28T08:48:08.334 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    2022-09-28T08:48:08.350 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-28T08:48:08.350 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 33 39
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 33 39
    2022-09-28T08:48:08.350 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 36 36 2E 39 30
    2022-09-28T08:48:08.350 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-28T08:48:08.366 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    2022-09-28T08:48:13.951 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 34
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 34
    2022-09-28T08:48:38.346 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    2022-09-28T08:48:38.346 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-28T08:48:38.346 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 37 36
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 37 36
    2022-09-28T08:48:38.362 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 36 37 2E 35 37
    2022-09-28T08:48:38.362 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-28T08:48:38.362 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 32
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 32
    2022-09-28T08:49:08.339 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    2022-09-28T08:49:08.354 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-28T08:49:08.354 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 37 36
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 37 36
    2022-09-28T08:49:08.354 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 36 37 2E 35 37
    2022-09-28T08:49:08.370 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-28T08:49:08.370 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    2022-09-28T08:49:20.542 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 36
    tx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 36
    2022-09-28T08:49:38.346 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    tx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    2022-09-28T08:49:38.361 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    tx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    2022-09-28T08:49:38.361 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 30 2E 30 31
    tx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 30 2E 30 31
    2022-09-28T08:49:38.361 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 36 38 2E 30 31
    2022-09-28T08:49:38.361 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    tx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-09-28T08:49:38.377 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    
    --- pulled the pug ---
    
    rx> PingReq(00):
    tx> PingResp(00):
    rx> PingReq(00):
    tx> PingResp(00):
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 19 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 00 29 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 6E 6C 69 6E 65 00 05 66 61 6C 73 65
    tx> ConnAck(00): 00 02
    Connections >> shellyplug-s-BCFF4D5A2607 was disconnected. Keep alive time overdue.
    Client      >> shellyplug-s-BCFF4D5A2607
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shellyplug-s-BCFF4D5A2607
      s: ..disconnected..
      msgIdSeq: 3
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 3
    
    PS >
    

    nmmqt_sub client for plotting the values:

    > nmqtt_sub -h "192.168.1.11" -p 1884 -q 2 -v 2 -t "shellies/shellyplug-s-BCFF4D5A2607/relay/0,shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy,shellies/shellyplug-s-BCFF4D5A2607/relay/0/power,shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value,shellies/shellyplug-s-BCFF4D5A2607/temperature,shellies/shellyplug-s-BCFF4D5A2607/overtemperature"
    Running nmqtt_sub v1.0.4
    Connecting to 192.168.1.11:1884
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0/power
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/temperature
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/overtemperature
    tx> Connect(00): 00 04 4D 51 54 54 04 02 00 3C 00 0D 6E 6D 71 74 74 73 75 62 2D 31 32 35 36
    rx> ConnAck(00): 00 00
    Connection established
    tx> Subscribe(02): 00 04 00 3A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 6F 76 65 72 70 6F 77 65 72 5F 76 61 6C 75 65 02
    tx> Subscribe(02): 00 05 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 02
    tx> Subscribe(02): 00 03 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 02
    tx> Subscribe(02): 00 02 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 02
    tx> Subscribe(02): 00 06 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 02
    tx> Subscribe(02): 00 01 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 02
    rx> SubAck(02): 00 04
    rx> SubAck(02): 00 05
    rx> SubAck(02): 00 03
    rx> SubAck(02): 00 02
    rx> SubAck(02): 00 06
    rx> SubAck(02): 00 01
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 30 2E 30 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 0.00
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 0
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 30 2E 30 35
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 20.05
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 32 34
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 50.24
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 30
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 0
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 34 39 2E 39 38
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 49.98
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 13
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 33 39
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 19.39
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 13
    tx> PingReq(00):
    rx> PingResp(00):
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 34
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 50.04
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 31 33
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 13
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 37 36
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 19.76
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 32
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 50.02
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 63
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 31 39 2E 37 36
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 19.76
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    tx> PingReq(00):
    rx> PingResp(00):
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 63
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 70 6F 77 65 72 35 30 2E 30 36
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/power: 50.06
    rx> Publish(00): 00 31 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 2F 65 6E 65 72 67 79 36 33
    shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy: 63
    rx> Publish(00): 00 2A 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 72 65 6C 61 79 2F 30 6F 6E
    shellies/shellyplug-s-BCFF4D5A2607/relay/0: on
    rx> Publish(00): 00 2E 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 32 30 2E 30 31
    shellies/shellyplug-s-BCFF4D5A2607/temperature: 20.01
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    shellies/shellyplug-s-BCFF4D5A2607/overtemperature: 0
    tx> PingReq(00):
    rx> PingResp(00):
    tx> PingReq(00):
    rx> PingResp(00):
    Closing: remote closed connection
    tx> Disconnect(00):
    Connecting to 192.168.1.11:1884
    Error connecting to 192.168.1.11
    The remote computer refused the network connection.
    
    Connecting to 192.168.1.11:1884
    Error connecting to 192.168.1.11
    The remote computer refused the network connection.
    
  7. ingoogni commented on Sep 28, 2022

    @ingoogni
    Author

    Without going through the whole process and would probably understand half of it I noticed: In keepAliveMonitor state is set to error. Then close() is called. close() does not check for error state.

  8. ingoogni commented on Sep 29, 2022

    @ingoogni
    Author

    Tested it today with Mosquitto, nmqtt_sub and the Shelly. No problem. I can reset the device, it goes off-line, comes back on-line and everything continues as it should. Same when I just pull the plug and put it back.

    Also tested it with HBMQTT broker (python). Same result, it works flawless.

    Hope it helps.

  9. ingoogni commented on Oct 8, 2022

    @ingoogni
    Author

    When I stop (ctrl-C or taskmanager) a nmqtt client, the broker prints

    Client      >> nmqtt_client_name
      [...]
      s: ..disconnected..
    

    The after ~60 seconds the broker prints:
    Connections >> nmqtt_client_name was disconnected. Keep alive time overdue.
    and continues as usual.

    When I pull a shelly plug, or reboot it the

    Client      >> shelly_client_name
      [...]
      s: ..disconnected..
    

    message from the broker is not there. The power to the client was cut so no "goobye message" could have been sent.

    Could this make the difference?

  10. ThomasTJdev commented on Oct 9, 2022

    @ThomasTJdev
    Collaborator

    Can you replicate it, if you only subscribe to a single topic per client?

    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0/energy
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0/power
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/relay/0/overpower_value
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/temperature
    Subscribing to: shellies/shellyplug-s-BCFF4D5A2607/overtemperature
    

    Could you try to clone the repo and change the output message? Then we can inspect the client data.

    $ git clone git@github.com:zevv/nmqtt.git
    $ nano nimqtt/nmqtt.nim
    # line 21
       await sleepAsync(keepAlive)
    +  verbose(ctx)
       if ctx.lastAction <= saveLastAction:
    $ nimble install
    

    I cannot recreate the scenario, so I can't force the error. But it could sound like, that the broker does not recognize that the client has disconnected, and then errors out on a dead client.

  11. ingoogni commented on Oct 9, 2022

    @ingoogni
    Author

    A way to recreate the problem I tested today: run a listener client on a laptop connected with wifi, run the broker on an other machine. Then turn off the wifi connection on the laptop. After ~ 60 sec the broker will quit.

    Below the output of the patched broker:

    2022-10-09T07:06:58.594 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 30 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 74 65 6D 70 65 72 61 74 75 72 65 5F 66 36 32 2E 35 33
    2022-10-09T07:06:58.594 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> Publish(00): 00 32 73 68 65 6C 6C 69 65 73 2F 73 68 65 6C 6C 79 70 6C 75 67 2D 73 2D 42 43 46 46 34 44 35 41 32 36 30 37 2F 6F 76 65 72 74 65 6D 70 65 72 61 74 75 72 65 30
    2022-10-09T07:06:58.604 Client  >> shellyplug-s-BCFF4D5A2607 has published a message
    rx> PingReq(00):
    tx> PingResp(00):
    
    -- disconnect shelly plug here
    
    Client      >> shellyplug-s-BCFF4D5A2607
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shellyplug-s-BCFF4D5A2607
      s: ..connected..
      msgIdSeq: 5
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 3
    
    Client      >> shelly_sub_plug_2152
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shelly_sub_plug_2152
      s: ..connected..
      msgIdSeq: 4
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic:
      willMsg:
      proto: MQTT
      version: 4
      connFlags: 00000010
      subscribed: 1
    
    rx> PingReq(00):
    tx> PingResp(00):
    Client      >> shellyplug-s-BCFF4D5A2607
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shellyplug-s-BCFF4D5A2607
      s: ..connected..
      msgIdSeq: 5
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 3
    
    Connections >> shellyplug-s-BCFF4D5A2607 was disconnected. Keep alive time overdue.
    Client      >> shellyplug-s-BCFF4D5A2607
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: shellyplug-s-BCFF4D5A2607
      s: ..disconnected..
      msgIdSeq: 5
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 3
    
    PS >
    
  12. ingoogni commented on Feb 12, 2024

    @ingoogni
    Author

    in nmqtt.nim, inside processClient I wondered how sendWill if diconnected? So I changed it to removeSubscriber as it has disconnected from the broker:

      if ctx.state == Error and ctx.beenConnected:
        # This happens on a ungraceful disconnects from the client.
        #asyncCheck sendWill(ctx)  
        asyncCheck removeSubscriber(ctx)
    

    and all seems to work fine now...?

  13. ThomasTJdev commented on Feb 15, 2024

    @ThomasTJdev
    Collaborator

    Hi @ingoogni

    Looks good. I'll schedule some tests before approving the PR. Maybe @srd424 will pitch in on the testing?

  14. ingoogni commented on Feb 15, 2024

    @ingoogni
    Author

    I'm still testing things. It is a strange problem and I have trouble following the flow. In what I did no Will will be send at all, that's not a proper solution. For some reason with the will part in it the server blips out of existance at the end of processClient.

  15. ingoogni commented on Feb 15, 2024

    @ingoogni
    Author

    A little step further, sendWill proc starts of with a test against ctx.willTopic. Should it not test against ctx.willFlag as the topic can have content but one does not want to send it. This is the case with the Shellies:

      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: shellies/shellyplug-s-BCFF4D5A2607/online
      willMsg: false
    
    when defined(broker):
      proc sendWill(ctx: MqttCtx) {.async.} =
        ## Send the will
        if ctx.willTopic != "":  ### should be   if ctx.willFlag: 
          for c in mqttbroker.subscribers[ctx.willTopic]:
            let msgId = c.nextMsgId()
            let qos = qosAlign(ctx.willQos, c.subscribed[ctx.willTopic])
            c.workQueue[msgId] = Work(wk: PubWork, msgId: msgId, topic: ctx.willTopic, qos: qos, message: ctx.willMsg, typ: Publish)
            await c.work()
    

    Now, after this change unplugging the device seems to works flawless. More testing needed.

    But now the question is why does the server crash without the change?? There is a topic and there is a message that can be send, regardless of the flag. Is the something wrong in the sending of the LWT?

  16. ingoogni commented on Feb 16, 2024

    @ingoogni
    Author

    Tested with a pristine install of nmmqt on win11.

    I wrote two clients. On standard one testclient1 where I set the will. I notice that in the server stdoutput that there is a will topic and message, but that the willFlag == false. After 20 s the client is made to crash and the server follows soon and crashes too.

    In the second client I added a modified 'set_will' that sets a will topic and message but with a willFlag == false. I notice that in the server stdoutput that there is no will topic or message and that the willFlag == false. After 20 s the client is made to crash, the server continues as it should.

    As I do not understand the flow and big chunks of (n)mqtt that's about what I can figure out. The problem seems to be connected with the willFlag somehow.

    testclient1.nim :

    import std/[times, strformat]
    from os import getCurrentProcessId
    include nmqtt
    
    let pid = getCurrentProcessId()
    
    let ctx = newMqttCtx(fmt"something_sub_{pid}")
    ctx.set_host("192.168.1.11", 1883)
    ctx.set_will("something/lwt","offline") #defaults to willFlag = true
    ctx.set_verbosity(3)
    
    proc mqttSub() {.async.} =
      await ctx.start()
      proc on_data(topic: string, message: string) =
        echo $getTime().utc.format("yyyy-MM-dd'T'HH:mm:ss'.'fff"),";", topic, ";", message
    
      await ctx.subscribe("something/from/somewhere", 2, on_data)
    
      var a:ptr[int]
      waitFor sleepAsync(20000) # wait 20 seconds before destruction
      echo a[]
    
    asyncCheck mqttSub()
    runForever()
    

    testclient2 :

    import std/[times, strformat]
    from os import getCurrentProcessId
    include nmqtt
    
    proc set_falsewill*(ctx: MqttCtx, topic, msg: string, flag=false, qos=0, retain=false) =
      ## Set the clients will.
      ctx.willFlag   = flag
      ctx.willTopic  = topic
      ctx.willMsg    = msg
      ctx.willQoS    = qos.uint8
      ctx.willRetain = retain
    
    let pid = getCurrentProcessId()
    
    let ctx = newMqttCtx(fmt"something2_sub_{pid}")
    ctx.set_host("192.168.1.11", 1883)
    ctx.set_falsewill("something/lwt","offline") #defaults to willFlag = false
    ctx.set_verbosity(3)
    
    proc mqttSub() {.async.} =
      await ctx.start()
      proc on_data(topic: string, message: string) =
        echo $getTime().utc.format("yyyy-MM-dd'T'HH:mm:ss'.'fff"),";", topic, ";", message
    
      await ctx.subscribe("something/from/somewhere", 2, on_data)
    
      var a:ptr[int]
      waitFor sleepAsync(20000) # wait 20 seconds before destruction
      echo a[]
    
    asyncCheck mqttSub()
    runForever()
    
    

    testclient1.exe output testclient2 is simmilar:

    PS C:\Users\me\mqtt\disconnect> .\testclient.exe
    Connecting to 192.168.1.11:1883
    tx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 12 73 6F 6D 65 74 68 69 6E 67 5F 73 75 62 5F 31 33 30 30 00 0D 73 6F 6D 65 74 68 69 6E 67 2F 6C 77 74 00 07 6F 66 66 6C 69 6E 65
    rx> ConnAck(00): 00 00
    Connection established
    tx> Subscribe(02): 00 01 00 18 73 6F 6D 65 74 68 69 6E 67 2F 66 72 6F 6D 2F 73 6F 6D 65 77 68 65 72 65 02
    rx> SubAck(02): 00 01
    Traceback (most recent call last)
    C:\Users\me\mqtt\disconnect\testclient.nim(23) testclient
    C:\Users\me\mqtt\disconnect\testclient.nim(21) mqttSub (Async)
    SIGSEGV: Illegal storage access. (Attempt to read from nil?)
    PS C:\Users\me\mqtt\disconnect>
    

    server output serving testclient1.exe:

    PS C:\Users\me\.nimble\pkgs2\nmqtt-1.0.6-926c1e352673c57dcb3cdefc20cf0ca5a454d81e\nmqtt> .\nmqtt.exe -h "192.168.1.11" -p 1883 -v=3
    Running nmqtt v1.0.6
    
    BROKER:
      Host:       192.168.1.11
      Port:       1883
      SSL:        false
      Starting:   2024-02-16T09:00:34+01:00
    
    OPTIONS:
      Verbosity:             3
      Max connections:       0
      ClientID max lenght:   60
      ClientID allow spaces: false
      ClientID allow empty:  false
      ClientID in payload:   false
      Client kick old:       false
      Number of passwords:   0
    
    
    rx> Connect(00): 00 04 4D 51 54 54 04 06 00 3C 00 12 73 6F 6D 65 74 68 69 6E 67 5F 73 75 62 5F 31 33 30 30 00 0D 73 6F 6D 65 74 68 69 6E 67 2F 6C 77 74 00 07 6F 66 66 6C 69 6E 65
    Connections >> something_sub_1300 has connected
    Client      >> something_sub_1300
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: something_sub_1300
      s: ..connected..
      msgIdSeq: 0
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false      <-- why is this false? it is set to true
      willQoS: 0
      willRetain: false
      willTopic: something/lwt
      willMsg: offline
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 0
    
    tx> ConnAck(00): 00 00
    rx> Subscribe(02): 00 01 00 18 73 6F 6D 65 74 68 69 6E 67 2F 66 72 6F 6D 2F 73 6F 6D 65 77 68 65 72 65 02
    Client      >> something_sub_1300 has subscribed to a topic
    Subscribers >> {something/from/somewhere: 1}
    tx> SubAck(02): 00 01
    Client      >> something_sub_1300   <-- after 20s the client is crashed intentionally
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: something_sub_1300
      s: ..disconnected..
      msgIdSeq: 1
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic: something/lwt
      willMsg: offline
      proto: MQTT
      version: 4
      connFlags: 00000110
      subscribed: 1
                                           <------------ server crash
    PS C:\Users\me\.nimble\pkgs2\nmqtt-1.0.6-926c1e352673c57dcb3cdefc20cf0ca5a454d81e\nmqtt>
    

    server output serving testclient2.exe:

    PS C:\Users\me\.nimble\pkgs2\nmqtt-1.0.6-926c1e352673c57dcb3cdefc20cf0ca5a454d81e\nmqtt> .\nmqtt.exe -h "192.168.1.11" -p 1883 -v=3
    Running nmqtt v1.0.6
    
    BROKER:
      Host:       192.168.1.11
      Port:       1883
      SSL:        false
      Starting:   2024-02-16T09:23:46+01:00
    
    OPTIONS:
      Verbosity:             3
      Max connections:       0
      ClientID max lenght:   60
      ClientID allow spaces: false
      ClientID allow empty:  false
      ClientID in payload:   false
      Client kick old:       false
      Number of passwords:   0
    
    
    rx> Connect(00): 00 04 4D 51 54 54 04 02 00 3C 00 14 73 6F 6D 65 74 68 69 6E 67 32 5F 73 75 62 5F 31 31 38 36 38
    Connections >> something2_sub_11868 has connected
    Client      >> something2_sub_11868
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: something2_sub_11868
      s: ..connected..
      msgIdSeq: 0
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic:
      willMsg:
      proto: MQTT
      version: 4
      connFlags: 00000010
      subscribed: 0
    
    tx> ConnAck(00): 00 00
    rx> Subscribe(02): 00 01 00 18 73 6F 6D 65 74 68 69 6E 67 2F 66 72 6F 6D 2F 73 6F 6D 65 77 68 65 72 65 02
    Client      >> something2_sub_11868 has subscribed to a topic
    Subscribers >> {something/from/somewhere: 1}
    tx> SubAck(02): 00 01
    Client      >> something2_sub_11868          <---- after 20s the client is crashed intentionally
      host:
      sslOn: false
      sslCert:
      sslKey:
      verbosity: 0
      beenConnected: true
      username:
      password:
      clientId: something2_sub_11868
      s: ..disconnected..
      msgIdSeq: 1
      workQueue: 0
      pubCallbacks: 0
      inWork: false
      keepAlive: 60
      willFlag: false
      willQoS: 0
      willRetain: false
      willTopic:
      willMsg:
      proto: MQTT
      version: 4
      connFlags: 00000010
      subscribed: 1
    
    Connections >> something2_sub_11868 was disconnected. Keep alive time overdue.
          <--- server continues.
    
  17. ingoogni commented on Feb 16, 2024

    @ingoogni
    Author

    it seems to met that the willFlag is not set in proc onConnect(ctx: MqttCtx, pkt: Pkt). Is that proper?

  18. ingoogni commented on Feb 20, 2024

    @ingoogni
    Author

    The following changes seem to fix the problem as far as I can test. Please test.

    First the willFlag had not been set in the context, adding the ctx.willFlag = true in proc onConnect(ctx: MqttCtx, pkt: Pkt) fixes that. Line 687, 688.

    fixed version:

    proc onConnect(ctx: MqttCtx, pkt: Pkt) {.async.} =
      when not defined(broker):
        ctx.wrn "Packet type only supported for broker: " & $pkt.typ
      else:
        var
          offset: int
          nextLen: uint16
    
        # Main data
        (ctx.proto, offset)     = pkt.getstring(0, true)
        (ctx.version, offset)   = pkt.getu8(offset)
        (ctx.connFlags, offset) = getbin(pkt, offset)
        (ctx.keepAlive, offset) = pkt.getu16(offset)
        (nextLen, offset)       = pkt.getu16(offset)
        (ctx.clientId, offset)  = pkt.getstring(offset, parseInt($nextLen))
        if not mqttbroker.spacesInClientId:
          ctx.clientid = ctx.clientid.replace(" ", "")
    
        # Will Topic
        if ctx.connFlags[5] == '1':
          ctx.willFlag = true       <--------------------- this line added
          (nextLen, offset)         = pkt.getu16(offset)
          (ctx.willTopic, offset)   = pkt.getstring(offset,  parseInt($nextLen))
          (nextLen, offset)         = pkt.getu16(offset)
          (ctx.willMsg, offset)     = pkt.getstring(offset,  parseInt($nextLen))
    
    etc.
    

    Then sending a will fails and crashes the server if there are no subscribers to it:

    current version:

    when defined(broker):
      proc sendWill(ctx: MqttCtx) {.async.} =
        ## Send the will
        if ctx.willTopic != "":
          for c in mqttbroker.subscribers[ctx.willTopic]:
            let msgId = c.nextMsgId()
            let qos = qosAlign(ctx.willQos, c.subscribed[ctx.willTopic])
            c.workQueue[msgId] = Work(wk: PubWork, msgId: msgId, topic: ctx.willTopic, qos: qos, message: ctx.willMsg, typ: Publish)
            await c.work()
    

    fixed version:

    when defined(broker):
      proc sendWill(ctx: MqttCtx) {.async.} =
        ## Send the will
        if ctx.willFlag:
          if mqttbroker.subscribers.hasKey(ctx.willTopic):
            for c in mqttbroker.subscribers[ctx.willTopic]:
              let msgId = c.nextMsgId()
              let qos = qosAlign(ctx.willQos, c.subscribed[ctx.willTopic])
              c.workQueue[msgId] = Work(wk: PubWork, msgId: msgId, topic: ctx.willTopic, qos: qos, message: ctx.willMsg, typ: Publish)
              await c.work()
    
  19. ingoogni commented on Apr 27, 2026

    @ingoogni
    Author

    Asked Claude about both proposed fixes above fwiw:

    Both fixes look correct and well-reasoned. Here's a breakdown:

    Fix 1 — Setting ctx.willFlag = true in onConnect
    This is a real bug. The broker parses the will topic/message from the connect packet when connFlags[5] == '1', but never sets ctx.willFlag. That field was only ever set via the client-side set_will() proc. So the broker's own ctx objects for remote clients never had willFlag set, making any check on it useless. This fix closes that gap.

    Fix 2 — Guarding sendWill with hasKey
    This is the crash fix. The original:

    if ctx.willTopic != "":
      for c in mqttbroker.subscribers[ctx.willTopic]:  # KeyError if no subscribers!

    directly indexes into the table without checking existence. If a client registered a will but nobody subscribed to that topic, the broker crashes with a KeyError on disconnect. The proposed fix correctly guards with both ctx.willFlag (now reliable thanks to Fix 1) and hasKey.

    One minor note: the original sendWill also doesn't check hasKey for c.subscribed[ctx.willTopic] inside the loop — if a subscriber somehow lost that topic entry, it would also crash. Worth adding a guard there too:

    proc sendWill(ctx: MqttCtx) {.async.} =
      if ctx.willFlag and mqttbroker.subscribers.hasKey(ctx.willTopic):
        for c in mqttbroker.subscribers[ctx.willTopic]:
          if not c.subscribed.hasKey(ctx.willTopic): continue  # extra safety
          let msgId = c.nextMsgId()
          let qos = qosAlign(ctx.willQos, c.subscribed[ctx.willTopic])
          c.workQueue[msgId] = Work(wk: PubWork, msgId: msgId, topic: ctx.willTopic, qos: qos, message: ctx.willMsg, typ: Publish)
          await c.work()

    Also worth double-checking that sendWill is actually being called in onDisconnect — looking at the code it's commented out there (#await sendWill(ctx)), so you'll want to uncomment that for the will to fire at all.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions