Skip to content

Comments

[shelly] Implement WebSocket keep alive for Gen2+ devices staying always connected#20268

Open
markus7017 wants to merge 25 commits intoopenhab:mainfrom
markus7017:shelly_aswsping
Open

[shelly] Implement WebSocket keep alive for Gen2+ devices staying always connected#20268
markus7017 wants to merge 25 commits intoopenhab:mainfrom
markus7017:shelly_aswsping

Conversation

@markus7017
Copy link
Contributor

The PR implements

  • Sending a WS ping every minute of the connection is open
  • The device should respond with WS PONG, which restarts the watchdog timer
  • Connection idle timeout has been reduced to 5min, which means about 4 retries if the bindings sends PIN every minute
  • Once the WS is connected this mechanism keeps the connection open until the thing gets reinitialized

PR #20069 and 20248 need to be merged first.

Ravi Nadahar and others added 25 commits February 20, 2026 19:10
Note: The class isn't fully thread-safe because that would mean to make all (final) field implementations thread-safe as well. But, the class itself is.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Note: The class isn't fully thread-safe because that would mean to make all (final) field implementations thread-safe as well. But, the class itself is.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
…profile immutable.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
…he ThingHandler

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
…s (since they can't be restarted)

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
…vlet

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
…ymore

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Markus Michels <markus7017@gmail.com>
Signed-off-by: Markus Michels <markus7017@gmail.com>
devices

Signed-off-by: Markus Michels <markus7017@gmail.com>
used)

Signed-off-by: Markus Michels <markus7017@gmail.com>
alwaysOn devices. The PONG will restart the watchdog. WS connection idle
time has been reduced to 5 min, which means about 4 retries if the
devices does not respond once per minute.

Signed-off-by: Markus Michels <markus7017@gmail.com>
@markus7017 markus7017 self-assigned this Feb 21, 2026
@markus7017 markus7017 added enhancement An enhancement or new feature for an existing add-on awaiting other PR Depends on another PR labels Feb 21, 2026
@markus7017
Copy link
Contributor Author

@Nadahar I added the keep alive mechanism and verified that connection timeout is set to 300sec. I tried to get the remaining idle time, but Jetty just returns the configured timeout value, not the current value

fyi: We can't use @OnWebSocketPong, because using Jetty 9.4.58, which is very old (current Jetty version is 12.x)

@Nadahar
Copy link
Contributor

Nadahar commented Feb 21, 2026

We can't use @OnWebSocketPong, because using Jetty 9.4.58, which is very old (current Jetty version is 12.x)

Ah, ok - but isn't there another way to register (not using annotations?).

@markus7017
Copy link
Contributor Author

yes. there is another listener interface, but than requires for method to be implemented and somehow interfered with the annotations (maybe you could only use one or the other)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting other PR Depends on another PR enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants