Problem with Anel HUT in latest snapshot (openHAB 2.4.0 Build #1399)

I have been using Openhab 2.4 for a while with snapshots.

A few weeks ago, in an early morning, I got errors with anel huts
I don’t know what version of Openhab 2.4 I had, yet I had it already for a few months

So I went back to an older openhab installation. (openHAB 2.3.0 Build #1260 ) (on my backup pine64)
I had no problems for 10 days.
Today I reinstalled my main pine 64
First with 2.3 Release build. No problems.

Then I installed the lastest snapshot (openHAB 2.4.0 Build #1399)

And I get again this error:

22:37:56.567 [ERROR] [ing.anel.internal.AnelConnectorThread] - Error occurred when sending UDP data to Anel device: 'wer da?'

java.lang.Exception: java.net.SocketException: maximum number of DatagramSockets reached

at org.openhab.binding.anel.internal.AnelUDPConnector.sendDatagram(AnelUDPConnector.java:140) ~[237:org.openhab.binding.anel:1.13.0.201810160911]

at org.openhab.binding.anel.internal.AnelConnectorThread.requestRefresh(AnelConnectorThread.java:208) [237:org.openhab.binding.anel:1.13.0.201810160911]

at org.openhab.binding.anel.internal.AnelBinding.refreshAll(AnelBinding.java:149) [237:org.openhab.binding.anel:1.13.0.201810160911]

at org.openhab.binding.anel.internal.AnelBinding.execute(AnelBinding.java:140) [237:org.openhab.binding.anel:1.13.0.201810160911]

at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:144) [195:org.openhab.core.compat1x:2.4.0.201810181356]

at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:166) [195:org.openhab.core.compat1x:2.4.0.201810181356]

Caused by: java.net.SocketException: maximum number of DatagramSockets reached

at sun.net.ResourceManager.beforeUdpCreate(ResourceManager.java:73) ~[?:?]

at java.net.AbstractPlainDatagramSocketImpl.create(AbstractPlainDatagramSocketImpl.java:77) ~[?:?]

at java.net.DatagramSocket.createImpl(DatagramSocket.java:337) ~[?:?]

at java.net.DatagramSocket.<init>(DatagramSocket.java:239) ~[?:?]

at java.net.DatagramSocket.<init>(DatagramSocket.java:196) ~[?:?]

at org.openhab.binding.anel.internal.AnelUDPConnector.sendDatagram(AnelUDPConnector.java:136) ~[?:?]

Higher up in the log I also see

22:33:16.195 [WARN ] [se.jetty.util.thread.ThreadPoolBudget] - Low configured threads: (max=8 - required=1)=7 < warnAt=8 for QueuedThreadPool[ServletModel-37]@4e577e{STARTING,8<=0<=8,i=0,q=0}[ReservedThreadExecutor@e95da3{s=0/1,p=0}]
same as https://community.openhab.org/t/low-configured-threads-warning/52084

(I don’t think it’s related, yet just in case I mention it )

config:list “(service.pid=org.openhab.anel)”

Pid: org.openhab.anel
BundleLocation: mvn:org.openhab.binding/org.openhab.binding.anel/1.13.0-SNAPSHOT
Properties:

   anel30.host = 192.168.1.130
   anel30.password =hidden
   anel30.udpReceivePort = 1330
   anel30.udpSendPort = 1430
   anel30.user = OpenHab30
   anel31.host = 192.168.1.131
   anel31.password = hidden
   anel31.udpReceivePort = 1331
   anel31.udpSendPort = 1431
   anel31.user = OpenHab31
   anel32.host = 192.168.1.132
   anel32.password =hidden
   anel32.udpReceivePort = 1332
   anel32.udpSendPort = 1432
   anel32.user = OpenHab32
   anel33.host = 192.168.1.133
   anel33.password =hidden
   anel33.udpReceivePort = 1333
   anel33.udpSendPort = 1433
   anel33.user = OpenHab50
   anel34.host = 192.168.1.134
   anel34.password = hidden
   anel34.udpReceivePort = 1334
   anel34.udpSendPort = 1434
   anel34.user = OpenHab34
   anel35.host = 192.168.1.135
   anel35.password =hidden
   anel35.udpReceivePort = 1335
   anel35.udpSendPort = 1435
   anel35.user = OpenHab35
   anel36.host = 192.168.1.136
   anel36.password =hidden
   anel36.udpReceivePort = 1336
   anel36.udpSendPort = 1436
   anel36.user = OpenHab36
   anel37.host = 192.168.1.137
   anel37.password =hidden
   anel37.udpReceivePort = 1337
   anel37.udpSendPort = 1437
   anel37.user = OpenHab37
   anel38.host = 192.168.1.138
   anel38.password = <hidden>
   anel38.udpReceivePort = 1338
   anel38.udpSendPort = 1438
   anel38.user = OpenHab38
   anel39.host = 192.168.1.139
   anel39.password = hidden
   anel39.udpReceivePort = 1339
   anel39.udpSendPort = 1439
   anel39.user = OpenHab39
   anel40.host = 192.168.1.140
   anel40.password =hidden
   anel40.udpReceivePort = 1340
   anel40.udpSendPort = 1440
   anel40.user = OpenHab40
   anel41.host = 192.168.1.141
   anel41.password =hidden
   anel41.udpReceivePort = 1341
   anel41.udpSendPort = 1441
   anel41.user = OpenHab41
   anel42.host = 192.168.1.142
   anel42.password = <hidden>
   anel42.udpReceivePort = 1342
   anel42.udpSendPort = 1442
   anel42.user = OpenHab42
   anel43.host = 192.168.1.143
   anel43.password = hidden
   anel43.udpReceivePort = 1343
   anel43.udpSendPort = 1443
   anel43.user = OpenHab43
   anel44.host = 192.168.1.144
   anel44.password = <hidden>
   anel44.udpReceivePort = 1344
   anel44.udpSendPort = 1444
   anel44.user = OpenHab44
   anel45.host = 192.168.1.145
   anel45.password =hidden
   anel45.udpReceivePort = 1345
   anel45.udpSendPort = 1445
   anel45.user = OpenHab45
   anel46.host = 192.168.1.146
   anel46.password =hidden
   anel46.udpReceivePort = 1346
   anel46.udpSendPort = 1446
   anel46.user = OpenHab46
   anel47.host = 192.168.1.147
   anel47.password =hidden
   anel47.udpReceivePort = 1347
   anel47.udpSendPort = 1447
   anel47.user = OpenHab47
   anel48.host = 192.168.1.148
   anel48.password =hidden
   anel48.udpReceivePort = 1348
   anel48.udpSendPort = 1448
   anel48.user = OpenHab48
   anel49.host = 192.168.1.149
   anel49.password =hidden
   anel49.udpReceivePort = 1349
   anel49.udpSendPort = 1449
   anel49.user = OpenHab49
   service.pid = org.openhab.anel

On the other Openhab instance the only setting difference is
Pid: org.openhab.anel
BundleLocation: mvn:org.openhab.binding/org.openhab.binding.anel/1.12.0-SNAPSHOT

so the 1.12 works and the 1.13 does not
Both installs are using the same configuration.

Any idea what could be the problem for my anel hut problems?

Some time ago I upgraded to 2.4 M5
Today I noticed the same error.

With about 20 anel huts, I wonder if it’s HUT related or openhab related.
And if it’s hut related, how can I figure out with which one it is?

I still have errors. Today I noticed this

12:01:47.416 [ERROR] [ing.anel.internal.AnelConnectorThread] - Error occurred when sending UDP data to Anel device: Sw_on6OpenHab48f
java.lang.Exception: java.net.SocketException: maximum number of DatagramSockets reached
	at org.openhab.binding.anel.internal.AnelUDPConnector.sendDatagram(AnelUDPConnector.java:140) ~[230:org.openhab.binding.anel:1.13.0.M5]
	at org.openhab.binding.anel.internal.AnelConnectorThread.sendSwitch(AnelConnectorThread.java:128) [230:org.openhab.binding.anel:1.13.0.M5]
	at org.openhab.binding.anel.internal.AnelBinding.internalReceiveCommand(AnelBinding.java:214) [230:org.openhab.binding.anel:1.13.0.M5]
	at org.openhab.core.binding.AbstractBinding.receiveCommand(AbstractBinding.java:94) [195:org.openhab.core.compat1x:2.4.0.M5]
	at org.openhab.core.events.AbstractEventSubscriber.handleEvent(AbstractEventSubscriber.java:45) [195:org.openhab.core.compat1x:2.4.0.M5]
	at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutBlacklistTiming(HandlerTask.java:82) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:104) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at org.apache.felix.eventadmin.impl.tasks.AsyncDeliverTasks$TaskExecuter.run(AsyncDeliverTasks.java:166) [3:org.apache.karaf.services.eventadmin:4.2.1]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.net.SocketException: maximum number of DatagramSockets reached
	at sun.net.ResourceManager.beforeUdpCreate(ResourceManager.java:73) ~[?:?]
	at java.net.AbstractPlainDatagramSocketImpl.create(AbstractPlainDatagramSocketImpl.java:77) ~[?:?]
	at java.net.DatagramSocket.createImpl(DatagramSocket.java:337) ~[?:?]
	at java.net.DatagramSocket.<init>(DatagramSocket.java:239) ~[?:?]
	at java.net.DatagramSocket.<init>(DatagramSocket.java:196) ~[?:?]
	at org.openhab.binding.anel.internal.AnelUDPConnector.sendDatagram(AnelUDPConnector.java:136) ~[?:?]
	... 13 more

it mentions “Sw_on6OpenHab48”

Openhab48 is a user for the hut, all my ANEL huts have different users

A few minutes after that, I have a similar error for another uses, thus another hut.

I assume it’s some kind of limitation of the object that makes the connection.
(“maximum number of DatagramSockets” makes me think that)

Maybe it’s related to memory:

              total      used         free         shared          buff/cache   available
             2036460     1096836       79692       29568           859932      866116
             1018224           0      1018224

this has to do with the max # of UDP sockets available

to check how many are currently open (look for UDP) (Linux command)

ss -s

I don’t remember now what is the current max setting and how to change it. I will look for it.

This may be a bug in the binding (not closing/releasing) some UDP sockets

edit: this is a very old binding… 3 year old actually openhab1-addons/bundles/binding/org.openhab.binding.anel at main · openhab/openhab1-addons · GitHub and the original developer is not really maintaining it :frowning:

ss -s
Total: 220 (kernel 0)
TCP:   98 (estab 22, closed 6, orphaned 0, synrecv 0, timewait 2/0), ports 0

Transport Total     IP        IPv6
*	  0         -         -        
RAW	  0         0         0        
UDP	  24        1         23       
TCP	  92        3         89       
INET	  116       4         112      
FRAG	  0         0         0    

yes I have noticed, yet I have 20 of these devices in my house and everything is based on it, so I’m stuck with it :frowning:

I hope 24 is not too much as this seems about right with the number of Anel HUT’s I have

24 total UDP sockets is not bad
you should try to see how many are being used when the error appears (if possible)
I still haven’t found how many are max :frowning: still looking

check with:

ss -u -a
State       Recv-Q Send-Q                                       Local Address:Port                                                        Peer Address:Port 

Not sure if no answer is good or bad

did you show all ? (-a)

yes

openhab@openhab:/etc/openhab2$ ss -u -a
State       Recv-Q Send-Q                                       Local Address:Port                                                        Peer Address:Port                
openhab@openhab:/etc/openhab2$ ss -u -a
State       Recv-Q Send-Q                                       Local Address:Port                                                        Peer Address:Port                
openhab@openhab:/etc/openhab2$ 

i don’t know what to say :slight_smile:
is anything running on that host?
something must be listening on UDP…

all of these: anelZZ.udpReceivePort = xxxx should show up

only openhab is running on this system

in the log I see

12:54:58.114 [INFO ] [smarthome.event.ItemStateChangedEvent] - anel40_Temperature changed from 25.8 to 25.9
12:54:58.133 [INFO ] [smarthome.event.ItemStateChangedEvent] - anel45_Temperature changed from 26.5 to 26.6
12:54:58.149 [INFO ] [smarthome.event.ItemStateChangedEvent] - anel43_Temperature changed from 26.2 to 26.3

so it does detect changes

the only thing that I can suggest is to open up an issue on github… it maybe a socket leak or something else

1 Like

A) Is that then for the anel hut addon or a general problem
B) if nothing is visible, and it seems to work, then I might be looking in the wrong place ?

no idea, but I didn’t see anyone posting problems related with java.net.SocketException: maximum number of DatagramSockets reached and searching github for DatagramSockets in the openhab organization shows nothing: Repository search results · GitHub

I would say: binding problem (UDP leak)

I don’t know why ss -u -a does not show up anything on your system… that’s very strange.

here is the output from my system:

root@homer:~# ss -u -a
State       Recv-Q Send-Q                                            Local Address:Port                                                Peer Address:Port   
ESTAB       0      0                                                     127.0.0.1:57366                                                  127.0.0.1:59535   
UNCONN      0      0                                                 172.16.13.100:domain                                                         *:*       
UNCONN      0      0                                                     127.0.0.1:domain                                                         *:*       
UNCONN      0      0                                                             *:bootps                                                         *:*       
UNCONN      0      0                                                             *:sunrpc                                                         *:*       
UNCONN      0      0                                                 172.16.13.100:ntp                                                            *:*       
UNCONN      0      0                                                     127.0.0.1:ntp                                                            *:*       
UNCONN      0      0                                                             *:ntp                                                            *:*       
UNCONN      0      0                                                 172.16.13.100:58019                                                          *:*       
UNCONN      0      0                                                             *:supfilesrv                                                        *:*       
UNCONN      0      0                                                     127.0.0.1:881                                                            *:*       
UNCONN      0      0                                                             *:21474                                                          *:*       
UNCONN      0      0                                                             *:mdns                                                           *:*       
UNCONN      0      0                                                             *:10001                                                          *:*       
ESTAB       0      0                                                     127.0.0.1:59535                                                  127.0.0.1:57366   
UNCONN      0      0                                                             *:39618                                                          *:*       
UNCONN      0      0                                                            :::3671                                                          :::*       
UNCONN      0      0                                          ::ffff:172.16.13.100:56933                                                         :::*       
UNCONN      0      0                                                            :::57062                                                         :::*       
UNCONN      0      0                                                            :::domain                                                        :::*       
UNCONN      0      0                                                            :::sunrpc                                                        :::*       
UNCONN      0      0                                 fe80::a28c:fdff:fe76:d3c%eth0:ntp                                                           :::*       
UNCONN      0      0                                                           ::1:ntp                                                           :::*       
UNCONN      0      0                                                            :::ntp                                                           :::*       
UNCONN      0      0                                                            :::supfilesrv                                                       :::*       
UNCONN      0      0                                                            :::mdns                                                          :::*       
UNCONN      0      0                                                            :::mdns                                                          :::*       
UNCONN      0      0                                          ::ffff:172.16.13.100:46641                                                         :::*       
UNCONN      0      0                                                            :::58965                                                         :::*       
UNCONN      0      0                                                            :::10001                                                         :::*       
UNCONN      0      0                                                            :::10001                                                         :::*       
UNCONN      0      0                                                            :::1900                                                          :::*       
UNCONN      0      0                                          ::ffff:172.16.13.100:35140                                                         :::*       
UNCONN      0      0                                                            :::3478                                                          :::*       
root@homer:~# ss -s
Total: 456 (kernel 543)
TCP:   368 (estab 187, closed 127, orphaned 0, synrecv 0, timewait 124/0), ports 383

Transport Total     IP        IPv6
*	  543       -         -        
RAW	  1         1         0        
UDP	  34        16        18       
TCP	  241       167       74       
INET	  276       184       92       
FRAG	  0         0         0        

root@homer:~# 

edit: are you running the command as root?

do you have other software otehr then openhab running on the system?
Everything else I needed, I run on different raspberry pi’s.