Skip to content
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

[homematic] Fixed for two (re)connection problems #9692

Merged
merged 7 commits into from
Jan 12, 2021
Merged

[homematic] Fixed for two (re)connection problems #9692

merged 7 commits into from
Jan 12, 2021

Conversation

MHerbst
Copy link
Contributor

@MHerbst MHerbst commented Jan 4, 2021

This PR focusses primarily on the solution of two connection problems:

  1. An additional fix for Jetty Buffer Exception / Homematic Discovery #6963 that allows the set a buffer size in case the buffer is too small
  2. By simplifying the coding and removing some additional requests to the gateway an issue with the re-connection was solved (fixes [homematic] No connection after CCU to Openhab connection interruption #8808)

Two additional commits are removing deprecations from the doc and replaced deprecated Java constructors.

Signed-off-by: Martin Herbst <develop@mherbst.de>
They were already marked as deprecated since several versions.

Signed-off-by: Martin Herbst <develop@mherbst.de>
- simplified coding for the communication with the gateway
- buffer size for communication is now configurable to avoid problems
with too small buffers
- Previous solution for #6963 was not sufficient. Should be finally done
with these changes

Signed-off-by: Martin Herbst <develop@mherbst.de>
ping requests could therefore be safely removed problems with the
automatic reconnection were solved.

Fixes #8808


Signed-off-by: Martin Herbst <develop@mherbst.de>
@MHerbst MHerbst requested a review from gerrieg as a code owner January 4, 2021 18:58
Comment on lines 146 to 119
} catch (UnsupportedEncodingException | ExecutionException | TimeoutException | InterruptedException e) {
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the catch explicit as it was before. I'd rather not have RuntimeExceptions get treated as IOExceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, accepted.

I have changed the catch clause and explicitly added IllegalArgumentException because this is throws by Jetty if the buffer is too small.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the buffer is too small, then why is sendMessage retrying the request when that happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, that it does not really make sense, but this would mean some additional changed in another place and I wanted to avoid to it together with these changes. It's on my to-do list for a larger refactoring.

@cpmeister cpmeister added the bug An unexpected problem or unintended behavior of an add-on label Jan 6, 2021
Signed-off-by: Martin Herbst <develop@mherbst.de>
}
if (logger.isTraceEnabled()) {
String result = new String(ret, config.getEncoding());
logger.trace("Client XmlRpcResponse (port {}):\n{}", port, result);
}
} catch (UnsupportedEncodingException | ExecutionException | TimeoutException | InterruptedException e) {
} catch (InterruptedException | ExecutionException | TimeoutException | IllegalArgumentException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that code that calls the send method will attempt to retry a request anytime an IOException is thrown. This should not be the case when an InterruptedException is thrown since the thread should exit as soon as possible when an interrupt occurs. So I suggest instead of catching the InterruptedException here, you instead throw it as far up the stack as possible.

But such a change is probably out of scope for this PR so feel free to make another PR with the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, see my comment above.

@cpmeister cpmeister added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jan 10, 2021
Signed-off-by: Martin Herbst <develop@mherbst.de>
@wborn wborn added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jan 11, 2021
Signed-off-by: Martin Herbst <develop@mherbst.de>
@MHerbst
Copy link
Contributor Author

MHerbst commented Jan 11, 2021

Sorry, I had to edit the file in the github editor because of some git problems in my Eclipse workspace. Unfortunately forgot to add two imports.

@cpmeister cpmeister added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jan 11, 2021
@kaikreuzer kaikreuzer merged commit 706af08 into openhab:main Jan 12, 2021
@kaikreuzer kaikreuzer added this to the 3.1 milestone Jan 12, 2021
@kaikreuzer kaikreuzer changed the title [homematic] Fix for two (re)connection problems [homematic] Fixed for two (re)connection problems Jan 12, 2021
@gerrieg
Copy link
Contributor

gerrieg commented Jan 13, 2021

@MHerbst This also fixes my reconnect problem, thank you!

@MHerbst MHerbst deleted the issue-8808 branch January 31, 2021 19:27
themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this pull request May 10, 2021
* Replace deprecated constructors
* Removed no longer existing settings from the documentation. They were already marked as deprecated since several versions.
* Refactored communication with the HM gateway
- simplified coding for the communication with the gateway
- buffer size for communication is now configurable to avoid problems
with too small buffers
- Previous solution for openhab#6963 was not sufficient. Should be finally done
with these changes
* Retrieving the duty cycle is sufficient to check connection
- ping requests could therefore be safely removed problems with the automatic reconnection were solved.
* Changed to explicit list of Exception

Fixes openhab#8808

Signed-off-by: Martin Herbst <develop@mherbst.de>
Signed-off-by: John Marshall <john.marshall.au@gmail.com>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
* Replace deprecated constructors
* Removed no longer existing settings from the documentation. They were already marked as deprecated since several versions.
* Refactored communication with the HM gateway
- simplified coding for the communication with the gateway
- buffer size for communication is now configurable to avoid problems
with too small buffers
- Previous solution for openhab#6963 was not sufficient. Should be finally done
with these changes
* Retrieving the duty cycle is sufficient to check connection
- ping requests could therefore be safely removed problems with the automatic reconnection were solved.
* Changed to explicit list of Exception

Fixes openhab#8808

Signed-off-by: Martin Herbst <develop@mherbst.de>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
* Replace deprecated constructors
* Removed no longer existing settings from the documentation. They were already marked as deprecated since several versions.
* Refactored communication with the HM gateway
- simplified coding for the communication with the gateway
- buffer size for communication is now configurable to avoid problems
with too small buffers
- Previous solution for openhab#6963 was not sufficient. Should be finally done
with these changes
* Retrieving the duty cycle is sufficient to check connection
- ping requests could therefore be safely removed problems with the automatic reconnection were solved.
* Changed to explicit list of Exception

Fixes openhab#8808

Signed-off-by: Martin Herbst <develop@mherbst.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[homematic] No connection after CCU to Openhab connection interruption
5 participants