-
-
Notifications
You must be signed in to change notification settings - Fork 101
Avoid spurious reconnects #355
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
Conversation
Adds a counter to avoid forcing a reconnect if the connection is back online by the next 2 tries
Codecov Report
@@ Coverage Diff @@
## main #355 +/- ##
==========================================
+ Coverage 85.16% 86.14% +0.98%
==========================================
Files 10 10
Lines 1173 1184 +11
Branches 172 173 +1
==========================================
+ Hits 999 1020 +21
+ Misses 102 94 -8
+ Partials 72 70 -2
Continue to review full report at Codecov.
|
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.
Please make the timeout_counter configurable. This will also aid in testing.
Can you add tests for this functionality?
I've added the basic tests, I'm unsure how to go about replacing the websockets pong response in a fixture to cause it to raise the timeout exception though |
I think you can disable the websocket connection by manually setting state to CLOSING. |
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.
WEBSOCKET_CLOSE_TRIES is confusing.
I would prefer WEBSOCKET_PING_TRIES.
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.
great!
@@ -21,6 +21,7 @@ | |||
CONF_UNIT_OF_MEASUREMENT = ha.CONF_UNIT_OF_MEASUREMENT | |||
CONF_USERNAME = ha.CONF_USERNAME | |||
CONF_WEBSOCKET_CLOSE_TIMEOUT = "websocket_close_timeout" | |||
CONF_WEBSOCKET_PING_TRIES = "WEBSOCKET_PING_TRIES" |
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.
We should use a consistent case for the value.
Maybe uppercase is better? Or even better, Use strEnum, so you can easily import all conf and default?
"ws://127.0.0.1:9000/CP_3", | ||
subprotocols=["ocpp1.6"], | ||
) as ws: | ||
cp = ChargePoint("CP_3_test", ws) |
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.
Suggest to add ws.state = CLOSING after this to prevent pongs.
Adds a counter to avoid forcing a reconnect if the connection is back online by the next 2 tries