OpenVPNAdapter icon indicating copy to clipboard operation
OpenVPNAdapter copied to clipboard

VPN Status Connecting only.

Open rakeshdev16 opened this issue 5 years ago • 19 comments

Hi,

I have followed the same steps as explained here as well as in your medium article. Everything works however when I try to connect the VPN status shows "Connecting" only and does not connect. Can you please tell me what could be the possible reason for this issue.

Thank you.

rakeshdev16 avatar Dec 14 '19 16:12 rakeshdev16

I also have same issue. Can you please help in solving this?

Ankur0713 avatar Jan 02 '20 11:01 Ankur0713

I am facing same issue. Please suggest ?

nirwanrajat avatar Jan 02 '20 12:01 nirwanrajat

Hi guys,

First of all, have you checked the log?

ss-abramchuk avatar Jan 02 '20 12:01 ss-abramchuk

Yes, I checked the log.... but no error or log is printed

nirwanrajat avatar Jan 02 '20 12:01 nirwanrajat

the Logs may not work there (in Extensions), you can debug it by attaching the target to process: (PacketTunnelProvider). but the extension may process very fast and you may not be able to attach it to debug process,

you can try it by the : https://github.com/mutualmobile/MMWormhole

i strongly suggest you to check the Bundle ID provided . tunnelProtocol.providerBundleIdentifier = "com.example.vpn.PacketTunnelProvider"

basheerpaliyathu avatar Jan 02 '20 12:01 basheerpaliyathu

Thanks @basheerpaliyathu ,I debug it by attaching the target to process and also by printing message on console.

Yes, I have checked my "providerBundleIdentifier" that is correct

nirwanrajat avatar Jan 02 '20 12:01 nirwanrajat

Hi @ss-abramchuk , i follow the Medium Tutorial ( https://medium.com/better-programming/how-to-build-an-openvpn-client-on-ios-c8f927c11e80 ) and your github also and i have re-created project many times but always facing the same problem. Even it is not throwing any error only stuck in connecting state then never change the VPN status.

nirwanrajat avatar Jan 03 '20 04:01 nirwanrajat

This is definitely configuration issue. Here you can download working project. Compare it with yours and make sure providerBundleIdentifier is really correct. I.e. if your app identifier is com.example.vpn-client then providerBundleIdentifier should be something like com.example.vpn-client.tunnel-provider.

ss-abramchuk avatar Jan 03 '20 07:01 ss-abramchuk

Thanks @ss-abramchuk for providing project. I check it with my project and i do it exactly same as yours but the result is still same "Connecting" and the "providerBundleIdentifier" is correct i have checked.

As i try with make some changes, like i change "username" key with "user" in ViewController but in "PacketTunnelProvider" it is "username" so in that case status change connecting->disconnecting->disconnected.

So i think "startTunnel()" method in "PacketTunnelProvider" class gets called and after that somewhere it stuck.

So i think it is not a configuration issue. If you have any suggestion please suggest. Thanks

nirwanrajat avatar Jan 03 '20 10:01 nirwanrajat

Check device log thoroughly, you need to check records containing bundle identifier of your tunnel provider. Also, try debuging startTunnel step by step. If you add _ = DispatchSemaphore(value: 0).wait(timeout: .now() + 20) at the beginning of the startTunnel method it will give you more time to attach to the process.

ss-abramchuk avatar Jan 04 '20 08:01 ss-abramchuk

BTW, if you use NSLog within tunnel provider you will see these log messages in the device log.

ss-abramchuk avatar Jan 04 '20 08:01 ss-abramchuk

I have corrected "PacketTunnelProvider" in my project and now I m getting "Update Required" error message on my iPhone in VPN settings.

ArohiMagotra avatar Jan 05 '20 07:01 ArohiMagotra

Hi @ss-abramchuk

Thanks for your response. I debug it in my code by adding breakpoint and it works fine and I find that OpenVPNAdapterDelegate below method is called infinitely in loop. It is printing below 3 messages (logMessage) in infinite loop:

"Contacting xx.xxx.xxx.xxx:xxx via TCPv4\n"

"Connecting to [xx.xxx.xxx.xxx]:xxx (xx.xxx.xxx.xxx) via TCPv4\n"

"Server poll timeout, trying next remote entry...\n"

Where xx.xxx.xxx.xxx:xxx is my server address.

func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleLogMessage logMessage: String) { NSLog("[Log] (logMessage)") print(logMessage) }

And func openVPNAdapter(_ openVPNAdapter: OpenVPNAdapter, handleEvent event: OpenVPNAdapterEvent, message: String?) this method is try again and again to reconnecting. This method change its state wait->reconnecting infinitely.

Now i am not sure why "Server poll timeout, trying next remote entry..." is happen. Can you please help?

nirwanrajat avatar Jan 06 '20 05:01 nirwanrajat

Hi @ss-abramchuk

I have resolved my issue. This issue is, when we get some error from server then try to reconnect VPN and it goes in infinite loop so it stuck in connecting state for infinite.

nirwanrajat avatar Jan 16 '20 04:01 nirwanrajat

Hi nirwanrajat , How did you fix it?

rakeshdev16 avatar Jan 16 '20 23:01 rakeshdev16

Hi @rakeshdev16

In my case i have some error at server end so it is throwing error as mention above by me. When get this error it goes to reconnect VPN and it start infinite loop i.e, "connecting->error->reconnecting->connecting".

After fixing error at server it works smooth.

First of all you check that your "startTunnel" method in "PacketTunnelProvider" is getting call or not. If it is not getting call that means your NetworkExtension Target is not configure correctly.

For checking your startTunnel method place a breakpoint in this method and then select "Debug->Attach to Process by PID or Name->" then in PID or Process Name write your Network Extension Target name. Now breakpoint in your startTunnel method works if it is getting call.

Feel free if you have any doubt.

nirwanrajat avatar Jan 17 '20 04:01 nirwanrajat

Hi guys, i'm following step by step and do my example. I have a problem: When i start VPN by button -> it's work and connect VPN successfull. But when i connect VPN in Settings iOS, it's stuck (like my video). Anyone has this problem?

Stuck_VPN_Connecting 1.mp4.zip

duyhct avatar May 07 '20 02:05 duyhct

r "startTunnel" method in "PacketTunnelProvider" is getting call or not.

@nirwanrajat Hello

i am try many time and create new project many time but this r "startTunnel" method in "PacketTunnelProvider" are not call. so can you please tell me how to configure this do you have any step to configure correctly please help me.

khatri6168 avatar May 26 '20 16:05 khatri6168

@ss-abramchuk Hey Sir Thank you for responding I set a breakpoint on the startTunnel function in NEPacketTunnelProvider we have created on network extension but It never calls I stack on connecting

amir-ardalanuk avatar Oct 07 '20 08:10 amir-ardalanuk