-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[keba] Robustness improvements on communication error #10399
Conversation
Signed-off-by: Michael Weger <weger.michael@gmx.net>
long stamp = System.currentTimeMillis(); | ||
if (!isKebaReachable()) { | ||
logger.debug("isKebaReachable() timed out after '{}' milliseconds", System.currentTimeMillis() - stamp); | ||
transceiver.unRegisterHandler(getHandler()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually believe that this is the issue. The handler is unregistered here, but never registered again afterwards.
Have you tried adding
transceiver.registerHandler(getHandler());
at the top of the else branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did. In this case the runnable seems to be executed to early. It throws the following exception during startup:
2021-03-30 20:25:55.371 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.NoSuchMethodError: 'com.google.gson.JsonElement com.google.gson.JsonParser.parseString(java.lang.String)'
at org.openhab.binding.keba.internal.handler.KeContactHandler.onData(KeContactHandler.java:239) ~[?:?]
at org.openhab.binding.keba.internal.handler.KeContactHandler.pollingRunnable(KeContactHandler.java:190) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
In the solution provided by this PR, the Handler is never unregistered. Thereby it is also not required to register it again, once the connection is re-established.
Only drawback of the current solution: Thing status is not set to offline on communication errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only drawback of the current solution: Thing status is not set to offline on communication errors.
As already mentioned: This is not really acceptable and we need to find a solution for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR with a proper solution.
It changes the state to OFFLINE and back to ONLINE, when the communication is re-established.
My comment #10399 (comment) was crap. The error was caused by the JsonParser update openhab/openhab-core#2244 done on TRUNK while I tested the solution using OH3.0.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the solution again :-|
The used UDP communication is not 100% reliable. Even in a switched network, some of the report polling requests do not receive a response. In order to avoid the sporadic OFFLINE/ONLINE events, I introduced isKebaReachable()
in the polling runnable again. This function checks the presence of the TCP port (reliable). Only if the TCP port cannot be reached, the Binding goes OFFLINE. It tries to go ONLINE again in the next polling round. In order to change back to ONLINE isKebaReachable()
must be successful AND data via UDP must be received.
On UDP timeouts, only a debug message is logged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds sensible to me.
Signed-off-by: Michael Weger <weger.michael@gmx.net>
Signed-off-by: Michael Weger <weger.michael@gmx.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
Signed-off-by: Michael Weger <weger.michael@gmx.net> Signed-off-by: John Marshall <john.marshall.au@gmail.com>
Signed-off-by: Michael Weger <weger.michael@gmx.net>
Signed-off-by: Michael Weger <weger.michael@gmx.net>
Signed-off-by: Michael Weger <weger.michael@gmx.net>
Signed-off-by: Michael Weger <weger.michael@gmx.net>
[keba] Robustness improvements on communication error
Fix of issue #10385
Keba Binding is set to offline on communication error (timeout) and changes back to online once the communication is re-established.
Tested:
org.openhab.binding.keba-3.1.0-SNAPSHOT-20210410.zip
Result: