Skip to content

Conversation

@TimoPtr
Copy link
Member

@TimoPtr TimoPtr commented Dec 11, 2025

Summary

This is an attempt to make the Websocket impl to react to a URL change.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Any other notes

This is an attempt because I'm not sure it is actually doing anything, I don't know if there are a use case where the URL change that is not already disconnecting the web socket. Maybe if the internal is still accessible, but changing wifi SSID does disconnect briefly the WS already.

@TimoPtr TimoPtr changed the base branch from main to feature/refactor_connection_info December 11, 2025 12:05
@TimoPtr TimoPtr requested a review from jpelgrom December 11, 2025 12:06
@jpelgrom
Copy link
Member

I don't know if there are a use case where the URL change that is not already disconnecting the web socket.

Changing from 5G (with public URL that also works when at home) to Wi-Fi (with internal IP) doesn't immediately trigger a disconnect for me, it takes the system a while to actively stop using 5G for network access for active connections and disconnect the websocket. With this change, I suppose that may happen sooner from the app's end now instead of waiting for the system to disconnect + the app to notice?

Comment on lines 290 to 291
// we abruptly cancel the connection since we might be in an insecure state
connection?.cancel()
Copy link
Member

Choose a reason for hiding this comment

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

  • Maybe introduce WebSocketState.CLOSED_URL_CHANGE for this?
  • In case the URL changes, do we want the same delay for reconnecting (10s) or none / a shorter delay?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍🏻

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's easy for you to test with 5G lemme know how it behaves on your side.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be too difficult, I'll test it tomorrow

@TimoPtr
Copy link
Member Author

TimoPtr commented Dec 15, 2025

I don't know if there are a use case where the URL change that is not already disconnecting the web socket.

Changing from 5G (with public URL that also works when at home) to Wi-Fi (with internal IP) doesn't immediately trigger a disconnect for me, it takes the system a while to actively stop using 5G for network access for active connections and disconnect the websocket. With this change, I suppose that may happen sooner from the app's end now instead of waiting for the system to disconnect + the app to notice?

Interesting, in that case I'm curious if you could test if you see a difference. I only tested changing Wi-Fi to another one.

@TimoPtr TimoPtr force-pushed the feature/refactor_connection_info branch from d68d1a4 to 456b172 Compare December 17, 2025 14:26
Base automatically changed from feature/refactor_connection_info to main December 17, 2025 15:05
@TimoPtr TimoPtr force-pushed the feature/websocket_disconnect_insecure branch from 31120ab to 7b56408 Compare December 17, 2025 15:48
@TimoPtr TimoPtr force-pushed the feature/websocket_disconnect_insecure branch from 7b56408 to 665e9ec Compare December 18, 2025 14:25
@TimoPtr TimoPtr requested a review from jpelgrom December 18, 2025 14:26
@jpelgrom
Copy link
Member

Sorry for the late response: testing when switching between 5G/Wi-Fi now shows immediate disconnects, with the system also immediately switching to the new connection when the websocket is restarted, and also immediate disconnects for trusted Wi-Fi/other Wi-Fi.

Testing note: if the websocket is returning a null URL it should probably be handled in the WebSocketManager's job to not indicate a connection in the notification while there is actually none, but that is out of scope of this PR.

@TimoPtr TimoPtr merged commit f49885e into main Dec 29, 2025
31 of 32 checks passed
@TimoPtr TimoPtr deleted the feature/websocket_disconnect_insecure branch December 29, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants