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

Workaroud for #290: delay the client-connect after concurrend disconnects #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bernhardkaindl
Copy link

Change-type: patch
Connects-to: #290

Due to e.g. network interruptions or a hardware/power-on reset of a BalenaOS device, the openvpn server can end up receiving a new connection from a openvpn client from which it believes that it still or already has an existing connection.

That existing connection could be from a no longer used, previous network connection or from the old boot of the BalenaOS device for example.

The OpenVPN server then replaces the old connection with the new connection, issues a client-disconnect event for the old connection and a client-connect event for the new connection, and both events happen at the same time.

If the device is unlucky, the client-connect event could get sent thru curl -X POST to the API before the client-disconnect event thru curl -X DELETE.

Of course, the precondition for this is that the server still believes that it has an old connection which it has to disconnect, when the reconnect happens.

This minimal workaround adds a sleep 1 before curl -s -X POST in the script to delay to POST to occur about one second after the DELETE and not concurrent.

An alternative, less simple solution would be to make the curl -X POST calls increment a connection counter and the curl -X DELETE calls decrement a counter of connections. The device would only be marked offline when this counter returns to 0.

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.

1 participant