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

Ensure local ws connections are closed on disconnect #255

Merged
merged 1 commit into from
May 2, 2024

Conversation

knolleary
Copy link
Member

Fixes FlowFuse/flowfuse#3751

When the device agent tunnel connection is dropped, we weren't closing down the local ws connection to Node-RED - however the platform side does tidy up the corresponding editor->platform connections. This meant that when the tunnel reconnects, the editors create new ws connections which in turn create new ws connections to Node-RED in the agent. This causes duplicate messages to be sent back over the proxy to the connected clients.

This fixes it by ensuring the local ws connections are closed if the tunnel closes.

Whilst debugging, it was also observed that if a tunnel fails to connect, we wouldn't retry the connection; the retry logic was only be applied if a connected socket is dropped unexpectedly.

This fixes that by not treating 'ECONNREFUSED' as a fatal error as it did before.

I've also increased the default reconnect timeout to 1.5s from 0.5s to give the remove end a bit more time to recover, with out any real impact on the user experience.

@knolleary knolleary requested a review from Steve-Mcl May 1, 2024 10:53
Copy link
Contributor

@Steve-Mcl Steve-Mcl left a comment

Choose a reason for hiding this comment

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

pulled locally & tested

I restarted the nginx container at least 15 times.
No sign of double debug messages ✅

@Steve-Mcl Steve-Mcl merged commit 8073793 into main May 2, 2024
4 checks passed
@Steve-Mcl Steve-Mcl deleted the clean-local-connections branch May 2, 2024 15:49
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.

Duplicate debug messages in Device Editor
2 participants