openvpn3 icon indicating copy to clipboard operation
openvpn3 copied to clipboard

When openvpn signnal "CONNECTED" event, it did not already connecetd , and tun deivice is not created in 4-5seconds

Open wsktree opened this issue 5 years ago • 6 comments

Now, I am creating a openvpn client using the API on win platform. I need to do something when I get the sinal of "CONENECTED" which means the vpn network is ok.

The issue is now, when I receiver the ”CONNECTED” event, the tun network device did not created finished, it takes 4-5 seoncds after get "CONNECED" event ,then the tun decice create and network is ok.

Could you help me if there any event or how can I know the network is ready ? Can you help to fix the issue after the "CONNECTED" event signaled, it takes 4-5 seconds to finish create the tun device ? The related of the code to signal the "CONNECTED " event is bellow: ==== in tuncli.hpp virtual void tun_start(const OptionList& opt, TransportClient& transcli, CryptoDCSetting&) overide { ................... if(!dhcp_capture) parent.tun_connected(); //signal that we are connected }

=== thanks very much! BR, wsktree

wsktree avatar Jul 16 '19 03:07 wsktree

You did you determine that CONNECTED is after the tun is created and opened? This might be something in the OS that is outside our control.

schwabe avatar Jul 17 '19 15:07 schwabe

Is there any API we can use to know the tun is created and opened ?

wsktree avatar Jul 18 '19 07:07 wsktree

Let me rephrase what I have written. CONNECTED is normally after tun is opened. How did you determine that this is not case?

schwabe avatar Jul 18 '19 10:07 schwabe

Hi schwabe,

I have a callback function when receiver the “CONNECTED“ EVENT。 In this callback function, I will use the VPN network, but in the 4-5seonds, it will always failed due to network error.

Then I run a script "ipconfig" to check the tun device when recevier the "CONNECTED" event. The result is the same: 1> script result shows the tun dev is not created in the 4-5 seconds 2> the callback is error dur to network issue So, i can confirm the 4-5seconds after the "CONNECTED" message, the tun created finish.

thanks! BR, wesktree

wsktree avatar Jul 18 '19 12:07 wsktree

Are you using the generic TunBuilderBase methods or one of the OS specific models for creating a tunnel?

In the former case it is up to you to return when the tunnel is created, so you control when OpenVPN will continue the connection process as it will block until you return from that function.

I do not have experience with the latter OS specific model cases, however I would be surprised if they return that the tunnel is set up before it actually is.

AnthonyWharton avatar Oct 02 '19 12:10 AnthonyWharton

Please share your implementation (point to a publicly available git repository or so), then it is easier to spot what's going on in your code.

dsommers avatar Oct 02 '19 17:10 dsommers