Wemo 'Address already in use' when moved to Debian

I have a running OpenHAB instance running on a Windows 8.1 client at the moment. This is working fine, but it’d be easier to manage on Linux, so I’m trying to move it to a Debian VirtualBox VM on the same machine.

This generally works - but I’m having some issues with the Wemo binding. It’s refusing to do any discovery and errors out with: Could not start wemo device discovery java.net.BindException: Address already in use

I’m using the same bindings and configs as the Windows box. The VM is running with a bridged network, so it has an IP address on the same subnet as the host. I’m at a bit of a loss? Any suggestions?

2015-08-21 13:10:48.999 [ERROR] [.o.b.wemo.internal.WemoBinding] - Could not start wemo device discovery
java.net.BindException: Address already in use
	at java.net.PlainDatagramSocketImpl.bind0(Native Method) ~[na:1.7.0_79]
	at java.net.AbstractPlainDatagramSocketImpl.bind(AbstractPlainDatagramSocketImpl.java:96) ~[na:1.7.0_79]
	at java.net.DatagramSocket.bind(DatagramSocket.java:396) ~[na:1.7.0_79]
	at org.openhab.binding.wemo.internal.WemoBinding.wemoDiscovery(WemoBinding.java:179) [bundlefile:na]
	at org.openhab.binding.wemo.internal.WemoBinding.wemoCall(WemoBinding.java:295) [bundlefile:na]
	at org.openhab.binding.wemo.internal.WemoBinding.sendCommand(WemoBinding.java:253) [bundlefile:na]
	at org.openhab.binding.wemo.internal.WemoBinding.internalReceiveCommand(WemoBinding.java:135) [bundlefile:na]
	at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:96) [org.openhab.core_1.7.1.jar:na]
	at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:42) [org.openhab.core_1.7.1.jar:na]
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:197) [org.eclipse.equinox.event_1.2.200.v20120522-2049.jar:na]
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197) [org.eclipse.equinox.event_1.2.200.v20120522-2049.jar:na]
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1) [org.eclipse.equinox.event_1.2.200.v20120522-2049.jar:na]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) [org.eclipse.osgi_3.8.2.v20130124-134944.jar:na]
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135) [org.eclipse.equinox.event_1.2.200.v20120522-2049.jar:na]
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78) [org.eclipse.equinox.event_1.2.200.v20120522-2049.jar:na]
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39) [org.eclipse.equinox.event_1.2.200.v20120522-2049.jar:na]
	at org.openhab.core.internal.events.EventPublisherImpl.sendCommand(EventPublisherImpl.java:56) [org.openhab.core_1.7.1.jar:na]
	at org.openhab.model.script.actions.BusEvent.sendCommand(BusEvent.java:84) [org.openhab.model.script_1.7.1.jar:na]
	at org.openhab.model.script.actions.BusEvent.sendCommand(BusEvent.java:51) [org.openhab.model.script_1.7.1.jar:na]

can you check your Java installation, and compare the versions on Debian and Windows?

Those should be same - at least JVM 1.8ff

Cheers
Karsten

Check netstat and see if something is running on that port already.

Java on the Debian VM:

java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

On the Windows 8.1 machine:

java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode)

So, slightly different I guess, but not fatally so I wouldn’t expect.

I did a netstat on the VM but couldn’t find anything that looked out of the ordinary (output below).

Since my post I’ve also tried updating the WEMO binding to the 1.8 snapshot. The code looked to be significantly improved so I thought it worth a shot. Using it I no longer get the error, but it also never discovers devices.

I’m wondering whether it’s a network routing issue? Something to do with SSDP packets (UPnP) traversing the bridge network of the VM? It’s a little beyond my knowledge though, so I’m not sure how to confirm this?

As a test I was going to package the same VM and get it running in VirtualBox on my mac. If this works, it’s not the VM, but the host. If it continues to fail, maybe Virtualbox related or the VM setup?

Netstat output from VM (sorry, it refused to format correctly in my other post)

vagrant@openhab:~$ netstat -ao
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer
tcp        0      0 *:microsoft-ds          *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:50241                 *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:nfs                   *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:59779                 *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:44038                 *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:57417                 *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 localhost:mysql         *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:netbios-ssn           *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:sunrpc                *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:55828                 *:*                     LISTEN      off (0.00/0/0)
tcp        0      0 *:ssh                   *:*                     LISTEN      off (0.00/0/0)
tcp        0    340 openhab.flatnet:ssh     192.168.2.151:52547     ESTABLISHED on (0.01/0/0)
tcp6       0      0 [::]:8090               [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:microsoft-ds       [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:nfs                [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:8099               [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:59747              [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:52805              [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:36361              [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:netbios-ssn        [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:48556              [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:53616              [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:8083               [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:8086               [::]:*                  LISTEN      off (0.00/0/0)
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      off (0.00/0/0)
udp        0      0 *:929                   *:*                                 off (0.00/0/0)
udp        0      0 localhost:977           *:*                                 off (0.00/0/0)
udp        0      0 *:54739                 *:*                                 off (0.00/0/0)
udp        0      0 *:nfs                   *:*                                 off (0.00/0/0)
udp        0      0 *:46098                 *:*                                 off (0.00/0/0)
udp        0      0 *:bootpc                *:*                                 off (0.00/0/0)
udp        0      0 *:sunrpc                *:*                                 off (0.00/0/0)
udp        0      0 openhab.flatnet:ntp     *:*                                 off (0.00/0/0)
udp        0      0 openhab.flatnet:ntp     *:*                                 off (0.00/0/0)
udp        0      0 localhost:ntp           *:*                                 off (0.00/0/0)
udp        0      0 *:ntp                   *:*                                 off (0.00/0/0)
udp        0      0 192.168.2.25:netbios-ns *:*                                 off (0.00/0/0)
udp        0      0 openhab.flat:netbios-ns *:*                                 off (0.00/0/0)
udp        0      0 *:netbios-ns            *:*                                 off (0.00/0/0)
udp        0      0 192.168.2.2:netbios-dgm *:*                                 off (0.00/0/0)
udp        0      0 openhab.fla:netbios-dgm *:*                                 off (0.00/0/0)
udp        0      0 *:netbios-dgm           *:*                                 off (0.00/0/0)
udp        0      0 *:47796                 *:*                                 off (0.00/0/0)
udp        0      0 *:46285                 *:*                                 off (0.00/0/0)
udp        0      0 *:33022                 *:*                                 off (0.00/0/0)
udp        0      0 *:55577                 *:*                                 off (0.00/0/0)
udp6       0      0 [::]:44916              [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:929                [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:40416              [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:54765              [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:nfs                [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:sunrpc             [::]:*                              off (0.00/0/0)
udp6       0      0 fe80::a00:27ff:fefd:ntp [::]:*                              off (0.00/0/0)
udp6       0      0 fe80::a00:27ff:fe77:ntp [::]:*                              off (0.00/0/0)
udp6       0      0 ip6-localhost:ntp       [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:ntp                [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:58081              [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:50432              [::]:*                              off (0.00/0/0)
udp6       0      0 [::]:10042              [::]:*                              off (0.00/0/0)
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     9000     /var/run/samba/nmbd/unexpected
unix  2      [ ACC ]     STREAM     LISTENING     9795     /var/run/mysqld/mysqld.sock
unix  2      [ ACC ]     STREAM     LISTENING     8521     /var/run/dbus/system_bus_socket
unix  2      [ ACC ]     STREAM     LISTENING     9293     /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     6612     @/com/ubuntu/upstart
unix  2      [ ACC ]     SEQPACKET  LISTENING     7270     /run/udev/control
unix  8      [ ]         DGRAM                    9102     /dev/log
unix  2      [ ACC ]     STREAM     LISTENING     8117     /run/rpcbind.sock
unix  3      [ ]         STREAM     CONNECTED     7254
unix  2      [ ]         DGRAM                    9290
unix  3      [ ]         STREAM     CONNECTED     9040
unix  3      [ ]         DGRAM                    7304
unix  3      [ ]         STREAM     CONNECTED     8048
unix  2      [ ]         DGRAM                    9686
unix  2      [ ]         DGRAM                    65911
unix  3      [ ]         STREAM     CONNECTED     8986
unix  3      [ ]         STREAM     CONNECTED     8985
unix  3      [ ]         STREAM     CONNECTED     66094
unix  3      [ ]         STREAM     CONNECTED     10065
unix  3      [ ]         STREAM     CONNECTED     66100    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     8968
unix  2      [ ]         DGRAM                    9808
unix  3      [ ]         STREAM     CONNECTED     8913
unix  3      [ ]         STREAM     CONNECTED     8969     /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     8906
unix  3      [ ]         STREAM     CONNECTED     7265     @/com/ubuntu/upstart
unix  3      [ ]         DGRAM                    7303
unix  3      [ ]         STREAM     CONNECTED     9041     /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     8076     @/com/ubuntu/upstart
unix  2      [ ]         STREAM     CONNECTED     9547
unix  2      [ ]         DGRAM                    29799
unix  3      [ ]         STREAM     CONNECTED     10066    /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     66099
unix  3      [ ]         STREAM     CONNECTED     8914
unix  2      [ ]         DGRAM                    11744
unix  3      [ ]         STREAM     CONNECTED     9055     @/com/ubuntu/upstart
unix  3      [ ]         STREAM     CONNECTED     66093

I’ve migrated the VM to OSX with no change.

Interestingly, I tried doing a UPnP browse with the command line tool gssdp-discover -i eth1 --timeout=3 and I get no response from the Belkin devices. If I visit them directly (eg. http://192.168.2.196:49153/setup.xml) I get the correct xml file - but they don’t seem to be responding to discovery requests.

Unfortuately, I don’t know enough to be sure if I’m barking up the wrong tree (or not). Anyone have any thoughts?

Hi Andre,
Could you give some information on the firmware versions your belkin devices are running.

Best
Hans-Jörg

From the XML response:

<root xmlns="urn:Belkin:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:Belkin:device:controllee:1</deviceType>
<friendlyName>LivingRoomLamp</friendlyName>
<manufacturer>Belkin International Inc.</manufacturer>
<manufacturerURL>http://www.belkin.com</manufacturerURL>
<modelDescription>Belkin Plugin Socket 1.0</modelDescription>
<modelName>Socket</modelName>
<modelNumber>1.0</modelNumber>
<modelURL>http://www.belkin.com/plugin/</modelURL>
<serialNumber>221448K110042D</serialNumber>
<UDN>uuid:Socket-1_0-221448K110042D</UDN>
<UPC>123456789</UPC>
<macAddress>94103E30EFAC</macAddress>
<firmwareVersion>WeMo_WW_2.00.9399.PVT-OWRT-SNS</firmwareVersion>
<iconVersion>0|49153</iconVersion>
<binaryState>0</binaryState>
<iconList>
<icon>
<mimetype>jpg</mimetype>
<width>100</width>
<height>100</height>
<depth>100</depth>
<url>icon.jpg</url>
</icon>
</iconList>

Hi,
just checked with my firmware, it’s the same.
Within your first post you wrote that it was running fine under Win8, just your VM’s are causing problems?
Did you try the same on your MAC ?

It could probably be the VM, you are using VirtualBox ? Could you try VMware ?

My IDE is running in a VMware VM with XUbuntu on my Windows7 machine and I am not seeing any problem.

How is your VMs network configured ? Sharing IP with host or bridged to get an individual IP. I use bridged mode for my VM’s.

Best Hans-Jörg

Ok good to know you’re using it successfully on a vm. I’m using virtualbox, with bridged networking, so the vm guest has an ip address on the same subnet as the host. So the only difference between us seems to be vmware / virtualbox.

So I eventually worked this out.

I had setup this VM using Vagrant, which by default doesn’t set a default route for networking. So while I could connect fine to the server, it wasn’t able to route broadcast messages (and discovery).

Now that I’ve added a default gateway in networking, it’s working fine.