OpenWebNet: failed CMD reconnect leaves commands disconnected on openHAB 5.2.3

Hi everyone,

I am running a fresh openHAB 5.2.3 installation using the official Docker image with host networking and a BTicino F459 as gateway. Things are configured through files; no previous binding runtime state was imported.

Commands initially work, but occasionally opening a replacement CMD connection fails. Subsequent commands then fail with “CMD is not connected” until the bridge is disabled and re-enabled.

There seem to be two separate questions: why opening a replacement command connection sometimes fails, and why subsequent commands do not recover afterwards.

Environment:

  • Current host: Intel Jasper Lake, Debian 13, kernel 6.12.113+deb13-amd64; official openHAB 5.2.3 Debian Docker image, host networking.
  • Things are file-configured, with JavaScript automation rules.
  • 37 OpenWebNet entries including the gateway: lighting, dimmers, shutters, heating, energy meter and CEN+.

For context, I previously used the same gateway with openHAB 4.3.1 on a Raspberry Pi 3 without noticing this behaviour. This is background information, not evidence of a version regression. That one is currently stopped and disabled; it is not intentionally running alongside the new one.

Observed behaviour:

  1. The gateway connects and commands initially work.
  2. A later command fails when the library tries to open a NEW CMD connection.
  3. Subsequent commands immediately fail with “CMD is not connected”.
  4. In earlier checks, the bridge could remain ONLINE with the monitor TCP socket still established despite command failures. I have not verified continuous event delivery during every incident.
  5. Disabling and re-enabling the bridge has restored the connection in observed incidents.

Example from 27 October 2026, local server time (Europe/Rome):

00:17:15.395 BUSConnector: openCommandConnection() returned exception
  (Could not open BUS-CMD connection to 192.168.1.45:20000
  (IOException: Connect timed out)) while opening NEW CMD connection
00:17:15.397 OpenWebNetLightingHandler: Exception while processing command ON:
  IOException while sending frame *1*1*24## or reading response:
  Cannot create NEW CMD connection to send message *1*1*24##
00:17:15.403 OpenWebNetLightingHandler: Exception while processing command OFF:
  CMD is not connected
00:17:18.418 OpenWebNetLightingHandler: Exception while processing command ON:
  CMD is not connected
00:17:20.504 OpenWebNetLightingHandler: Exception while processing command OFF:
  CMD is not connected
00:17:23.099 Custom recovery script disables the bridge
00:17:28.478 OpenWebNetBridgeHandler: CONNECTED to BUS gateway bridge

The excerpt above is shortened for readability; the recovery script is mine, not built-in binding behaviour. It checks for new CMD errors every 10 seconds, disables the bridge for 5 seconds and enables it again, with a 120-second cooldown. It sends no actuator commands. This work
around changes how long the failure remains observable.

Across the retained logs I found six failed CMD reconnects: 26 October at 22:18, 22:47, 23:01 and 23:03, and 27 October at 00:17 and 00:25. Five reported a connection timeout and one a refused connection. These are six failed reconnect attempts, not necessarily six independent ro
ot-cause incidents. The two incidents on 27 October were followed by successful bridge reconnection approximately 13 seconds after the first logged error.

There were also MON reconnect failures during setup, so I would not assume every incident affects only the CMD connection. Errors from the earlier intentionally isolated staging configuration have been excluded from the CMD count above.

Possible recovery issue, based on reading openwebnet4j 0.14.0:

  • BUSConnector.sendCommandSynchInternal() closes the old CMD socket, clears isCmdConnected and attempts openCmdConn(). If that fails, it throws an IOException.
  • OpenConnector.sendCommandSynch() rejects later commands when isCmdConnected() is false, before calling the internal send method.

Could this explain the persistent “CMD is not connected” state after one failed reconnect, or is another recovery mechanism expected to handle it?

Source references:

I have seen suggestions that a faster host might overwhelm older gateways. I am open to testing command pacing, but currently have no command-rate measurements or packet capture proving overload. A TCP connect timeout alone does not seem sufficient to establish that explanation.

Questions for the maintainers:

  1. Are there known session limits, idle-session behaviour or issues that could cause this pattern?
  2. Is the CMD recovery path above expected, and would reconnect-with-backoff or a more accurate Thing status be appropriate?
  3. Which logger categories and capture details would be most useful to distinguish TCP/session exhaustion from authentication or BUS timing problems?
  4. Would an isolated comparison with a single manually commanded light and automation rules disabled be the best next test?

I can collect a targeted trace and packet capture during a reproduction, with credentials/authentication exchanges removed before sharing. Thanks for any guidance.

Update - 28 October: a lost bedroom shutter command and passive socket observations

The issue happened again this morning during normal use. I used the openHAB Android app to open the bedroom shutter. The command reached o
penHAB, but the shutter did not open until I tried again after the bridge recovered.

The following timeline comes from events.log and openhab.log. All times are local, Europe/Rome:

Time Observation
08:27:22.044 Bedroom_Shutters_Position receives UP.
08:27:22.046 Optimistic autoupdate changes its state from 100 to 0. This does not confirm physical movement.
08:27:27.055 BUSConnector reports a timeout while opening a NEW CMD connection to the F459.
08:27:31.933 A BUS energy reading still updates, showing that the monitor/event path is working during the command failure.
08:27:33.091 My custom recovery script disables the bridge.
08:27:38.422 The bridge reconnects.
08:27:41.282 and 08:27:43.082 Further UP commands are received from the user.
08:28:15.347 The shutter position updates to 0 from the binding.

The key error is:

2026-10-28 08:27:27.055 [WARN ] [nwebnet4j.communication.BUSConnector] - ##BUS-conn## openCommandConnection() returned exception (Could not open BUS-CMD connection to 192.168.1.45:20000 (IOException: Connect timed out)) while opening NEW CMD connection

The bridge recovery is my workaround, not automatic recovery provided by the binding. It does not replay commands. Therefore, reconnecting the bridge does not recover the user’s original failed command. This is a practical reliability problem, not just a warning in the logs. The optimistic UI state also makes the failure harder to notice.

New observation: the command connection closes after approximately 30 seconds

Later, I passively sampled TCP socket states on the openHAB host every two seconds using ss. This observer opened no connections and sent no BUS commands:

12:57:37  Monitor connection: ESTABLISHED
          Old command connection: CLOSE-WAIT
12:57:43  Old command socket has disappeared
          New command connection: ESTABLISHED
          Monitor connection remains ESTABLISHED
12:58:13  New command connection: CLOSE-WAIT
          Monitor connection remains ESTABLISHED

This indicates that the gateway closed its side of the new command connection roughly 30 seconds after it appeared. In this particular cycle the binding successfully reopened the command connection without the custom bridge reset.

I am not treating CLOSE-WAIT by itself as a socket leak or an error: lazy reuse of a connection closed by the gateway can explain that state. The question is why reopening sometimes times out, and why that failed attempt leaves subsequent commands disconnected.

The comments in BUSConnector 0.14.0 describe a 120-second idle timeout for CMD connections. Could the shorter interval observed on this F459 be relevant to the reconnect handling? I do not yet have a packet capture establishing the cause of the failed connection attempt.

I also found this existing issue:

It describes the same persistent CMD is not connected behaviour after a network failure, with a different initial trigger. It may be related to the recovery path, but it does not establish the cause of the initial timeout here.

I have prepared a passive recorder of TCP SYN/FIN/RST metadata and socket states to catch the next occurrence. It records no application payloads or authentication exchanges. It has not yet been confirmed running, and no packet-level conclusion is being claimed.

Questions:

  1. Is an approximately 30-second CMD idle close expected for an F459 with firmware 2.1.4?
  2. Is issue #21546 relevant to this failure-to-recover path, and is there a fix or a binding/library build you would recommend testing?
  3. Which additional diagnostics would help explain why a new CMD TCP connection sometimes times out while the monitor connection continues working?

As a workaround, I created a rule to restart the binding when log reader detects the ‘cmd is not connected’ log entries

Thanks, I currently use a similar workaround, disabling and re-enabling the gateway bridge. Unfortunately, the triggering command is still lost.

I have now captured an occurrence at TCP level: after the gateway closes the idle CMD connection, the host sends a SYN and four retransmissions, with no SYN-ACK observed. A later reconnect succeeds immediately.

Have you seen failures during normal operation too, or only after network interruptions? Which gateway model and firmware are you using?

I have only seen the issue after router reboots. I have a dual NAT setup, so I don’t know which router reboot causes the issue. Both routers reboot automatically when OH detects network issues. Usually this is due to dropped LTE broadband connection.

I am using MH202 as gateway but I think I had similar issues with the screen10 as gateway too. No idea what firmware they run.

BTicino F459 and recent Linux kernels: TCP timestamp incompatibility and a scoped HAProxy workaround

Recent Linux kernels include a security fix for CVE-2026-23247 that changes how TCP timestamp offsets are randomized. On my installation, this exposed a compatibility problem with the old TCP stack in a BTicino F459: new OpenWebNet connections intermittently timed out, while an established monitor connection could continue receiving events.

What changed

Previously, Linux calculated the random TCP timestamp offset from the source and destination IP addresses. Connections between the same two hosts therefore shared a timestamp clock even when their TCP ports differed.

The security fix also incorporates the TCP ports. New connections between the same hosts can consequently have very different timestamp offsets. This addresses a TCP source-port information leak; it is an intentional security improvement, not a defect in the new kernel. In Debian, the fix was included in kernel package 6.12.94-1.

This concerns TCP timestamps

Old Linux kernels have a defensive mechanism, associated with tcp_tw_recycle, that remembers a recent timestamp for each peer IP and can silently drop a new SYN if its timestamp appears to go backwards. That per-host assumption conflicts with timestamps whose offsets now vary by host and port. The comparison uses signed 32-bit arithmetic, so ordinary decimal ordering can be misleading.

This was the behaviour observed with my F459 after moving from Linux 6.1.21 to 6.12.113: connection attempts with timestamps going backwards relative to the preceding command session received no SYN-ACK; subsequent attempts with timestamps going forwards succeeded. Giving the gateway a consistent timestamp clock stopped the failures. We cannot read the gateway’s internal tcp_tw_recycle setting, but the observed compatibility problem and the working workaround are reproducible in this installation.

Keep the security fix, isolate the compatibility setting

The F459 runs an old embedded Linux kernel, and I cannot rely on a future vendor firmware update to make it compatible. Instead, I put an HAProxy TCP relay between openHAB and the gateway:

openHAB -> local HAProxy TCP relay -> F459

The proxy runs in its own Docker network namespace with:

sysctls:
  net.ipv4.tcp_timestamps: "2"

Value 2 keeps TCP timestamps enabled but disables their random offset. Backend connections created by the proxy therefore use a consistent timestamp clock across different ports.

The host stays at net.ipv4.tcp_timestamps=1, with the new security behaviour enabled. Only connections originating in the dedicated proxy namespace use the compatibility setting. This avoids weakening timestamp randomization across the rest of the operating system. It is a scoped compatibility tradeoff, not a replacement for the security fix.

openHAB itself can remain in host networking, preserving its normal discovery behaviour.

Configuration

Create the following files in a dedicated directory. The image is the official HAProxy 3.2 Alpine image, pinned to the digest used in my test.

compose.yaml

name: openwebnet-proxy
services:
  proxy:
    image: haproxy@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
    container_name: openwebnet-proxy
    restart: unless-stopped
    user: "65534:65534"
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    sysctls:
      net.ipv4.tcp_timestamps: "2"
    ports:
      - "127.0.0.1:20001:20000"
    volumes:
      - type: bind
        source: ./haproxy.cfg
        target: /usr/local/etc/haproxy/haproxy.cfg
        read_only: true
        bind:
          create_host_path: false
    logging:
      driver: local
      options:
        max-size: "10m"
        max-file: "3"

The proxy must use its own network namespace: do not set network_mode: host on it.

haproxy.cfg

global
    log stdout format raw local0
    maxconn 16
    nbthread 1

defaults
    log global
    mode tcp
    option tcplog
    retries 0
    timeout connect 4s
    timeout client 24h
    timeout server 24h
    timeout client-fin 30s
    timeout server-fin 30s

frontend openwebnet
    bind :20000
    default_backend f459

backend f459
    server gateway 192.168.1.45:20000

Replace 192.168.1.45 with the gateway’s address. These are the timeout/retry settings used for this test; 24h is an inactivity timeout, not a fixed session lifetime.

Make the configuration readable by the container user, validate it, and start the proxy:

chmod 644 haproxy.cfg
sudo docker compose run --rm --no-deps proxy haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg
sudo docker compose up -d

Change the openHAB gateway Thing endpoint to 127.0.0.1:20001, preserving its password, UID and child Things. Stop openHAB during the switch and leave it stopped for approximately 75 seconds before restarting, to let the old peer timestamp state expire. No F459 reboot was needed here.

The loopback endpoint assumes openHAB runs directly on the host or in a host-networked container. A bridge-networked openHAB container needs an appropriately reachable proxy address instead.

Verify the settings:

cat /proc/sys/net/ipv4/tcp_timestamps
# Host: still 1

sudo docker exec openwebnet-proxy cat /proc/sys/net/ipv4/tcp_timestamps
# Proxy: 2

Check that the gateway Thing is ONLINE and test a light or shutter. The proxy is bound only to loopback, introduces no application probes or command replay, and does not increase the F459’s connection capacity.

Result and wider relevance

With openHAB 5.2.3 on Debian 13 / Linux 6.12.113, the first 24 hours through the proxy produced 200 successful new connections, no SYN retransmissions, no OpenWebNet connection errors and no bridge recovery interventions. Lights and shutters have been reliable during normal use.

This compatibility issue is not inherently specific to the F459 or openHAB. Other legacy devices that enforce a similar per-IP timestamp check can encounter the same conflict when their clients adopt timestamp offsets based on IP addresses and ports. The relevant factor is that legacy TCP behaviour, not simply the age or brand of the device.

References:

I have read the problem highlighted by @giacob (and his AI :winking_face_with_tongue:), and by @m4rk : the latest analysis points out a compatibility problem introduced by Debian updates.
Still I think the OpenWebNet binding should treat timed-out CMD connection properly and not get stuck until a restart of the binding.
Problem is I could not reproduce the issue yet in my setup and in the time I had to test it.
So the issue opened by @m4rk is valid and once solved should also solve the compatibility problems introduced by Debian.
Will let you know here when e fix is available for the binding.

I can reproduce the problem and already found a solution.
The issue corresponds to the behavior described here and also in the issue by @m4rk : a failure of CMD and subsequent new CMD connection, for example caused by socket timeout or temporary router reboot, blocks sending new commands while the MON connection may be still in place thus leaving the connection to the gateway as open and thus the binding does not start a connection recovery process.
I am already working on a solution which should be available in the next milestones.

Guilty as charged :grinning_face_with_smiling_eyes: But credit where it’s due: without GPT Astra’s help, I’d probably still be staring at unanswered SYNs, wondering what I’d done to upset my gateway. Connecting those to a change in Linux’s TCP timestamp handling was definitely beyond my networking detective skills.

I deliberately asked it to write up the complete solution because I find isolating net.ipv4.tcp_timestamps=2 inside the proxy’s network namespace particularly elegant: the old gateway gets compatible TCP behaviour, while the rest of the host keeps the kernel’s security fix. Hopefully that saves other people some head-scratching too.

Perhaps we can give it a second assignment: teaching the library to recover gracefully after a failed CMD connection, rather than holding a grudge against the gateway :wink:

Joking aside, thanks for your work on the library. Hopefully these findings help the next person keep their shutters moving!

In fact the best solution to this has been already suggested by my AI :sweat_smile: