bytespider / Meross

Investigating the Meross/Refoss MSS310 Smart Plug and getting these devices to communicate with our private MQTT brokers
113 stars 19 forks source link

MSS425 fails to connect to MQTT #41

Closed C0ntroller closed 3 years ago

C0ntroller commented 3 years ago

Hey guys,

I don't even know if here is the right place to ask this but I need some help. I got MSS425 smart surge protector and a local MQTT server.

Running meross setup ... works fine, connection to wifi too. But the device wont stop blinking. The log from the MQTT server shows the problem:

meross-mqtt | 1636472729: New connection from 172.16.0.xxx:58709 on port 8883.
meross-mqtt | 1636472729: New client connected from 172.16.0.xxx:58709 as fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (p1, c1, k30, u'xx:xx:xx:xx:xx:xx').
meross-mqtt | 1636472739: Client fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH disconnected.
meross-mqtt | 1636472742: New connection from 172.16.0.xxx:58710 on port 8883.
meross-mqtt | 1636472742: New client connected from 172.16.0.xxx:58710 as fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (p1, c1, k30, u'xx:xx:xx:xx:xx:xx').
...

This does happen to infinity. Starting mosquitto with verbose output is logging:

meross-mqtt | 1636473181: New connection from 172.16.0.xxx:58768 on port 8883.
meross-mqtt | 1636473181: New client connected from 172.16.0.xxx:58768 as fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (p1, c1, k30, u'xx:xx:xx:xx:xx:xx').
meross-mqtt | 1636473181: No will message specified.
meross-mqtt | 1636473181: Sending CONNACK to fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (0, 0)
meross-mqtt | 1636473181: Received SUBSCRIBE from fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH
meross-mqtt | 1636473181:       /appliance/1804260831712629081034298f158de3/subscribe (QoS 1)
meross-mqtt | 1636473181: fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH 1 /appliance/1804260831712629081034298f158de3/subscribe
meross-mqtt | 1636473181: Sending SUBACK to fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH
meross-mqtt | 1636473181: Received PUBLISH from fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (d0, q1, r0, m386, '/appliance/1804260831712629081034298f158de3/publish', ... (306 bytes))
meross-mqtt | 1636473181: Sending PUBACK to fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (m386, rc0)
meross-mqtt | 1636473183: Received PUBLISH from fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (d0, q1, r0, m387, '/appliance/1804260831712629081034298f158de3/publish', ... (306 bytes))
meross-mqtt | 1636473183: Sending PUBACK to fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (m387, rc0)
meross-mqtt | 1636473185: Received PUBLISH from fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (d0, q1, r0, m388, '/appliance/1804260831712629081034298f158de3/publish', ... (306 bytes))
meross-mqtt | 1636473185: Sending PUBACK to fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (m388, rc0)
meross-mqtt | 1636473187: Received PUBLISH from fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (d0, q1, r0, m389, '/appliance/1804260831712629081034298f158de3/publish', ... (306 bytes))
meross-mqtt | 1636473187: Sending PUBACK to fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (m389, rc0)
meross-mqtt | 1636473189: Received PUBLISH from fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (d0, q1, r0, m390, '/appliance/1804260831712629081034298f158de3/publish', ... (306 bytes))
meross-mqtt | 1636473189: Sending PUBACK to fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH (m390, rc0)
meross-mqtt | 1636473191: Received DISCONNECT from fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH
meross-mqtt | 1636473191: Client fmware:1804260831712629081034298f158de3_4Wvskv3yzf52FUeH disconnected.

What can I do to fix the connection?

EDIT: I forgot my server config for my mosquitto server. Here it is:

listener 8883

allow_anonymous true
require_certificate false

cafile /certs/ca.crt

certfile /certs/server.crt
keyfile /certs/server.key
bytespider commented 3 years ago

Are you able to subscribe to '/appliance/1804260831712629081034298f158de3/publish and see what the message it's repeatedly expecting a response to.

C0ntroller commented 3 years ago

It's just a clock timestamp...

{
  "header": {
    "messageId": "7a434a4233e888e5777548651601a686",
    "namespace": "Appliance.System.Clock",
    "method": "PUSH",
    "payloadVersion": 1,
    "from": "/appliance/1804260831712629081034298f158de3/publish",
    "timestamp": 3831,
    "timestampMs": 892,
    "sign": "a4d6a8e1e48ecd00138c0cbdc94fe59c"
  },
  "payload": {
    "clock": {
      "timestamp": 3831
    }
  }
}
bytespider commented 3 years ago

Do you allow access to external web? I know that Meross devices try to time sync with:

C0ntroller commented 3 years ago

No I don't. But if thats necessary I can create a custom rule for one of these servers.

bytespider commented 3 years ago

Have a go and see if it works. You could always reroute those urls to a local NTP server. Unfortunately they are hardcoded and wont recognise DHCP NTP params

C0ntroller commented 3 years ago

Nice, it worked! Thank you very much!