OpenVPNAdapter
OpenVPNAdapter copied to clipboard
VPN Status Connecting only.
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.
I also have same issue. Can you please help in solving this?
I am facing same issue. Please suggest ?
Hi guys,
First of all, have you checked the log?
Yes, I checked the log.... but no error or log is printed
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"
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
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.
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
.
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
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.
BTW, if you use NSLog
within tunnel provider you will see these log messages in the device log.
I have corrected "PacketTunnelProvider" in my project and now I m getting "Update Required" error message on my iPhone in VPN settings.
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?
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.
Hi nirwanrajat , How did you fix it?
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.
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?
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.
@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