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

WS Client over OpenVPN does not reconnect after tunnel reconnects #106

Open
Dash83UPV opened this issue Jun 17, 2024 · 0 comments
Open

WS Client over OpenVPN does not reconnect after tunnel reconnects #106

Dash83UPV opened this issue Jun 17, 2024 · 0 comments

Comments

@Dash83UPV
Copy link

Dear all
As always, thank you for your hard work

In Windows 10, I have been doing some long time testing to our application and I have found a possible issue.
We connect using WS and mantain the connection during the whole life of the application.

Due to the nature of our project, the Surreal DataBase is located in a Virtualized environment where we connect using OpenVPN.

I have looking at the logs of the OpenVPN client and it reconnects every hour. i.e.:

[Jun 17, 2024, 09:45:46] SSL Handshake: peer certificate: CN=server, 2048 bit RSA, cipher: TLS_AES_256_GCM_SHA384         TLSv1.3 Kx=any      Au=any   Enc=AESGCM(256)            Mac=AEAD
[Jun 17, 2024, 10:45:46] Tunnel Options:V4,dev-type tun,link-mtu 1603,tun-mtu 1500,proto TCPv4_CLIENT,keydir 1,cipher AES-256-CBC,auth SHA512,keysize 256,tls-auth,key-method 2,tls-client
[Jun 17, 2024, 10:45:46] Creds: UsernameEmpty/PasswordEmpty
[Jun 17, 2024, 10:45:46] Sending Peer Info:

[Jun 17, 2024, 10:45:46] SSL Handshake: peer certificate: CN=server, 2048 bit RSA, cipher: TLS_AES_256_GCM_SHA384         TLSv1.3 Kx=any      Au=any   Enc=AESGCM(256)            Mac=AEAD
[Jun 17, 2024, 11:45:46] Tunnel Options:V4,dev-type tun,link-mtu 1603,tun-mtu 1500,proto TCPv4_CLIENT,keydir 1,cipher AES-256-CBC,auth SHA512,keysize 256,tls-auth,key-method 2,tls-client
[Jun 17, 2024, 11:45:46] Creds: UsernameEmpty/PasswordEmpty
[Jun 17, 2024, 11:45:46] Sending Peer Info:

Then we have noticied that the SurrealDb.NET client looses connection and we have to set a timer to disconnect and reconnect every 30 minutes.
Then we can guarantee that the connection is available when a user requires data.


private void initializeReconnectTimer()
{
    timer = new System.Timers.Timer()
    {
        AutoReset = true,
        Enabled = true,
        Interval = RECONNECT_TIMER,
    };
    timer.Elapsed += Timer_Elapsed;
    timer.Start();
}

private bool isReconecting;

private void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
{
    if (isConnected)
    {
        isReconecting = true;
        Disconnect();
        Thread.Sleep(WAIT_TIME_FOR_RECONNECT);
        Connect(ipAddress, port, dbUsername, dbPassword, database);
        isReconecting = false;
    }
}

To test this behaviour, just establish the SurrealDB server behind a OpenVPN tunnel and manually disconnect and reconnect the tunnel.
The SurrealDB.NET client WS should not recover from this.

Could you kindly take a look at it.

Best regards.

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

No branches or pull requests

1 participant