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

Add websocket option update on component variable change #263

Merged

Conversation

klemmpnx
Copy link
Contributor

  • if certain ControllerComponentVariables are changed, updates the websocket options (without a reconnect)
  • removes the reset of connection_attempts on option settings since
    • unclear, why this is part of setting the connection options (which does not have further side effects)
    • so far, in libocpp set_connections_options is only called in the context of a websocket init (which implies connection_attempts=0)

@klemmpnx klemmpnx requested a review from Pietfried November 14, 2023 16:08
@klemmpnx klemmpnx self-assigned this Nov 14, 2023
@Dominik-K
Copy link
Contributor

I suggest to better make it explicit in the options itself.

One way could be to split up the WebsocketConnectionOptions into two parts: WebsocketConnectionOptionsNeedsReconnect and WebsocketConnectionOptionsNoReconnect. That way it's clearly indicated directly at the source of the fields what it means when changing them.

Perhaps you have a better idea, though?

Co-authored-by: Dominik-K <[email protected]>
Signed-off-by: Fabian Klemm <[email protected]>
@klemmpnx
Copy link
Contributor Author

I suggest to better make it explicit in the options itself.

One way could be to split up the WebsocketConnectionOptions into two parts: WebsocketConnectionOptionsNeedsReconnect and WebsocketConnectionOptionsNoReconnect. That way it's clearly indicated directly at the source of the fields what it means when changing them.

Perhaps you have a better idea, though?

Hmm yes that is tricky.

I do not quite understand the intention how the Websocket class is to be used. The Websocket class does offer the set_connections_options method, but does not really take care of it. I would actually expect that if I change options that require a re-connect, then the Websocket would take care of this. But this would be purely internal, so the outside classes would not need to care - so also (at least from the outside) not split would be required.
However, we already do care outside (in case the basic auth settings change). And in fact the Websocket does nothing when options are changed....

So if we want to refactor this, I would rather make the websocket API safer instead of putting more knowledge/responsibility outside (and then also kick out this distinction between with/without reconnect). But I am not 100% aware of all implications here and also not sure, this should go into this PR then?

@Pietfried
Copy link
Contributor

I suggest to better make it explicit in the options itself.
One way could be to split up the WebsocketConnectionOptions into two parts: WebsocketConnectionOptionsNeedsReconnect and WebsocketConnectionOptionsNoReconnect. That way it's clearly indicated directly at the source of the fields what it means when changing them.
Perhaps you have a better idea, though?

Hmm yes that is tricky.

I do not quite understand the intention how the Websocket class is to be used. The Websocket class does offer the set_connections_options method, but does not really take care of it. I would actually expect that if I change options that require a re-connect, then the Websocket would take care of this. But this would be purely internal, so the outside classes would not need to care - so also (at least from the outside) not split would be required. However, we already do care outside (in case the basic auth settings change). And in fact the Websocket does nothing when options are changed....

So if we want to refactor this, I would rather make the websocket API safer instead of putting more knowledge/responsibility outside (and then also kick out this distinction between with/without reconnect). But I am not 100% aware of all implications here and also not sure, this should go into this PR then?

There are quite some implications that need to be considered when changing the internal websocket handling and unfortunately the requirements of v16 and v201 differ a little bit concerning the change of ws options / reconnect / fallback handling. I agree that a general refactor makes sense, but I see this as part of another PR.

@klemmpnx klemmpnx marked this pull request as ready for review November 16, 2023 09:20
@klemmpnx klemmpnx merged commit 6bfdb5a into main Nov 16, 2023
@klemmpnx klemmpnx deleted the feature/fk-update-websocket-connection-options-on-dm-change branch November 16, 2023 09:20
valentin-dimov pushed a commit that referenced this pull request Nov 16, 2023
* add websocket option update on component variable change

Signed-off-by: Fabian Klemm <[email protected]>

* Update lib/ocpp/v201/charge_point.cpp

Co-authored-by: Dominik-K <[email protected]>
Signed-off-by: Fabian Klemm <[email protected]>

---------

Signed-off-by: Fabian Klemm <[email protected]>
Co-authored-by: Dominik-K <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants