Bridge goes offline

Hello! I have a problem with the work of Xiaomi Bridge. Il.p normally connects and works for some time (and sensors too), but after an hour or more it goes offline.
To return it online, you must restart OpenHub or turn off/on the Thing in PaperUI.

heartbeat every 10 seconds in log:

2018-12-31 02:27:46.269 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-2946,5,main] waiting for data on port 9898

2018-12-31 02:27:56.234 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.1.15:4321 on Port 9898

2018-12-31 02:27:56.236 [TRACE] [internal.handler.XiaomiBridgeHandler] - Received message {"cmd":"heartbeat","model":"gateway","sid":"04cf8c744c39","short_id":"0","token":"BIMZCMeHa1XixHt7","data":"{\"ip\":\"192.168.1.15\"}"}

2018-12-31 02:27:56.240 [TRACE] [internal.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 04cf8c744c39

2018-12-31 02:27:56.246 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Cancelled running timer

2018-12-31 02:27:56.249 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"heartbeat","model":"gateway","sid":"04cf8c744c39","short_id":"0","token":"BIMZCMeHa1XixHt7","data":"{\"ip\":\"192.168.1.15\"}"}

2018-12-31 02:27:56.253 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners

2018-12-31 02:27:56.255 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-2946,5,main] waiting for data on port 9898

Last heartbeat and bridge goes offline:

018-12-31 02:28:06.219 [DEBUG] [.mihome.internal.socket.XiaomiSocket] - Received Datagram from 192.168.1.15:4321 on Port 9898

2018-12-31 02:28:06.222 [TRACE] [internal.handler.XiaomiBridgeHandler] - Received message {"cmd":"heartbeat","model":"gateway","sid":"04cf8c744c39","short_id":"0","token":"s3CdI0MhyLiaw5Lj","data":"{\"ip\":\"192.168.1.15\"}"}

2018-12-31 02:28:06.225 [TRACE] [internal.handler.XiaomiBridgeHandler] - Updated "last time seen" for device 04cf8c744c39

2018-12-31 02:28:06.231 [DEBUG] [internal.handler.XiaomiBridgeHandler] - Cancelled running timer

2018-12-31 02:28:06.234 [DEBUG] [rnal.handler.XiaomiDeviceBaseHandler] - Item got update: {"cmd":"heartbeat","model":"gateway","sid":"04cf8c744c39","short_id":"0","token":"s3CdI0MhyLiaw5Lj","data":"{\"ip\":\"192.168.1.15\"}"}

2018-12-31 02:28:06.238 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Data received and notified 1 listeners

2018-12-31 02:28:06.240 [TRACE] [.mihome.internal.socket.XiaomiSocket] - Thread Thread[Thread-2946,5,main] waiting for data on port 9898

==> /var/log/openhab2/events.log <==

2018-12-31 02:33:06.249 [hingStatusInfoChangedEvent] - 'mihome:bridge:04cf8c744c39' changed from ONLINE to OFFLINE

2018-12-31 02:33:06.264 [hingStatusInfoChangedEvent] - 'mihome:sensor_weather_v1:158d000273cd11' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

2018-12-31 02:33:06.272 [hingStatusInfoChangedEvent] - 'mihome:gateway:4cf8c744c39' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

2018-12-31 02:33:06.278 [hingStatusInfoChangedEvent] - 'mihome:sensor_magnet_aq2:158d000276c39f' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

2018-12-31 02:33:06.283 [hingStatusInfoChangedEvent] - 'mihome:86sw2:158d0002b49c8a' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

2018-12-31 02:33:06.293 [hingStatusInfoChangedEvent] - 'mihome:sensor_plug:158d0001e8838c' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

2018-12-31 02:33:06.299 [hingStatusInfoChangedEvent] - 'mihome:sensor_motion_aq2:158d0002b7641a' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

2018-12-31 02:33:06.306 [hingStatusInfoChangedEvent] - 'mihome:gateway:04cf8c744c39' changed from ONLINE to OFFLINE (BRIDGE_OFFLINE)

Bridge info:

Version code:213
网关ID:130080011
Zigbee通道:25
网关信息:
{"life":444998,"cfg_time":0,"token":"18fd8f1ac717e6a28fea65955d8ffef1","mac":"04:CF:??:??:??:??","fw_ver":"1.4.1_161","hw_ver":"MW300","model":"lumi.gateway.v3","mcu_fw_ver":"0143","wifi_fw_ver":"SD878x-14.76.36.p84-702.1.0-WM",
"ap":{"rssi":-40,"ssid":"Fig_Vam","bssid":"bssid"},
"netif":"localIp":"192.168.1.15","mask":"255.255.255.0",
"gw":"192.168.1.1","gw_mac":"mac"},
"mmfree":166000,"ot":"ott",
"otu_stat":[438,404,320,29,239,1069],"ott_stat":[117,4,444,963]}

子设备信息:
[{"model":"lumi.plug.v1","did":"lumi.158d0001e8838c","name":"Mi Smart Plug"},
{"model":"lumi.weather.v1","did":"lumi.158d000273cd11","name":"Temp"},
{"model":"lumi.sensor_magnet.aq2","did":"lumi.158d000276c39f","name":"Aqara Door and Window Sensor"},
{"model":"lumi.remote.b286acn01","did":"lumi.158d0002b49c8a","name":"Switch"},{"model":"lumi.sensor_motion.aq2","did":"lumi.158d0002b7641a","name":"Aqara Motion Sensor"}]

Any ideas ?

Hey,

You should read this thread => Openhab2 - Xiaomi Mi Gateway - does not respond

Looks like your issue enter in this case.

Hi,
I have the exact same issue, but related to the mentioned thread :

In their case the port is closed.

In my case I have the same as described in this issue (61889) and the port is open :
$ sudo nmap -sU -p9898 10.10.80.2

Starting Nmap 7.40 ( https://nmap.org ) at 2019-01-09 14:37 CET
Nmap scan report for 10.10.80.2
Host is up (0.054s latency).
PORT STATE SERVICE
9898/udp open monkeycom

If anyone has an idea …

Are you really sure the port is open. It has been report that port sometimes respond as open, sometimes as closed. The gateway may open the port 9898 for some reasons during initialization or pairing.

Try to send command nmap multiple times at different moment, just to be sure your problem is different.

Ok, I changed my firewall setup to forward multicast … and this resolved my issue.
I wonder why it was online for some time and then went off.

Could you please serve more details :slight_smile:
I have se same issue.

Mu Access point does not forward multicast frames within the same network, so I routed the traffic.
I suppose this is specific to my Access point.

After setting up routing and configured the router (in fact a firewall) in order to forward multicast across the other networks, it worked.

Does the Xiaomi Bridge needs multicast?

I have a newly installed MW3 Tenda Mesh Wifi (in bridge mode on a Telekom Speedport Smart Router) and since then (not sure if it was before already) I got my gateway not automatically recognizes in PaperUI and if I do it with the things file, it is online for like 5 min, updates the temperature sensors and goes back to bridge offline…

Is that the issue?

EDIT:
Additional unfortunately german info I found on the tenda mesh:
9. Probleme mit IP-TV von der Telekom Media Receiver

Die Nova Systeme unterstützen kein Multicasting. Damit das Streaming auch mit den Novas reibungslos funktioniert, wird zusätzlich ein IGMPV3 Switch* benötigt. Dieser muss dazwischen geschaltet werden. Ein passender Switch ist zum Beispiel dieser hier:

Hi all… is a little fustrating trying to make this working… first the 9898 port closed, and now problems with multicast…
I have, I think, the same problem, as no communication with Xiaomi in a while, Bridge goes offline.

I have OpenHab over a Windows 10 computer, Xiaomi Gateway v3 with latest firmware. Checking some router configurations, I have seen with Wireshark that with some configurations, multicast packets from Xaiomi Gateway (destination IP: 224.0.0.50, port 4321 to 9898) are arriving to the computer… but only are seen with network card in promiscuous mode, not in “normal mode”, so OpenHab aren’t receiving the packets.

Anyone with this issue?

Thanks in advance.

Did you make it work?

Well…, I made it work, but after a restart of Windows 10 it does not work again and I have not been able to make it working again. I’ve been testing many things and in the end I have not been able to reproduce the same behavior that do the packets arrive again in non-promiscuous mode. I was trying route commands and some other network commands.

Binding also has a bug and does not work well when the system has more than one network interface (as usual, since at least the loopback exists apart from the external one). There is a special version of the binding that open a socket in each one of the interfaces that the computer has that I managed to make it work.

But at the moment I have not been able to reproduce that behavior again and I am quite discouraged that it costs so much to start it up.

The binding issue is explained here, and the “special” compiled one is there: https://github.com/openhab/openhab2-addons/issues/3239

Ruben

Thank you for your reply. I disconnected all the other network adapters and it’s working again. I believe it has something to do with the system listening on the wrong interface for the multicast. I think one workaround would be to forward the multicast across all the subnets your OH device is linked to or just disable all other interfaces.

Yes, I would be probably what I do in any of my tests under Windows 10, but I can’t reproduce it again :frowning: