Xiaomi Binding - Not listening on the right interface for port 9898 inside a docker container with docker-compose

Hi, I’m trying to make the Xiaomi Binding work within a docker-compose container.
In order to do it, I’ve added the following lines in the service definition:
network_mode: “host”
- 9898:9898/udp
- 9898:9898/tcp

Using paper-ui I can add the binding and things.
Registered the right developer key.

Initially, all the things look online but after a while (timeout), they become off-line except for the Xiaomi Mi Smart Home Bridge that it still online.

Trying to send a command to the gateway I get the following error:
2018-08-10 12:42:23.735 [WARN ] [g.mihome.handler.XiaomiBridgeHandler] - No token received from the gateway yet. Unable to encrypt the access key.
2018-08-10 12:42:23.738 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.mihome.handler.XiaomiActorGatewayHandler@44cae98c’: null
java.lang.NullPointerException: null

Inside the container, I’ve tried to sniff the 9898 port and it happens it can get the messages from the Xiaomi gateway, as expected:

tcpdump -A  -s0 -vv port 9898
tcpdump: listening on enp3s0, link-type EN10MB (Ethernet), capture size 262144 bytes
12:33:38.853621 IP (tos 0x0, ttl 255, id 2283, offset 0, flags [none], proto UDP (17), length 163)
    lumi-gateway-v3_miio78xxxxxxx.station.4321 > [udp sum ok] UDP, length 135

Inside the same network, another non-docker installation of openHAB works as a charm: sends commands and receives data.

I guess, the problem is which interface the binding, through openaHAB, is watching.

How can I specify which interface the binding should use to listen on 9898?



do you fix your problem?

Only one container could use the host network.
Container use host network do not need to forward ports.


Hi guys. Any solutions to this issue?