6 Replies
      Latest reply on Jan 14, 2020 2:26 AM by eskimo
      sjain7389 Level 1 Level 1 (0 points)

        I am unable to connect VPN using PacketTunnel. I have successfully created network extension target and when i call 'startVPNTunnel()' function it shows the status "VPN is connecting..." in 'NEVPNStatusDidChange' observer and after that status never change.

        It is not showing any kind of error also.

         

        As i debug, 'startTunnel()' function is never called in 'PacketTunnelProvider' class which is subclass of 'NEPacketTunnelProvider'. Even this class init method is also never getting called.

         

        If i have some problem on server side then in that case is it also possible that startVPNTunnel() does not get call? or it returns some other error?

         

        NOTE: I have added the NetworkExtension capabilities for both the target i.e, App main target and NetworkExtension Target.

         

        NOTE: I also added 'NSExtensionPointIdentifier' and 'NSExtensionPrincipalClass' keys in NetworkExtension target plist fie.

        • Re: VPN is not connecting
          eskimo Apple Staff Apple Staff (12,725 points)

          If i have some problem on server side then in that case is it also possible that startVPNTunnel does not get call?

          No.  A packet tunnel provider is a form of custom VPN, which means that the provider is responsible for all interactions with the server.  The system has no idea how your server works, and thus can’t possibly be talking to it, and that means that there’s nothing your server could be doing ‘wrong’.

          Failures like this are usually the result of a packaging problem in your app, that is, there’s something in your app, or in the nested appex, that’s preventing the system from loading your appex.

          Even this class init method is also never getting called.

          How are you testing that?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

          ps DTS is closed 21 Dec through 1 Jan.

            • Re: VPN is not connecting
              sjain7389 Level 1 Level 1 (0 points)

              Even this class init method is also never getting called.

               

              How are you testing that?

              I am trying by printing message in init method. But nothing is print on console.

               

                override init() {

                      super.init()

                      print("Hello")

                      NSLog("provider init")

                  }

               

              And i also check it by applying breakpoint and set Debug->Attach to process->Then i add NetworkExtension Target.

               

               

              Failures like this are usually the result of a packaging problem in your app, that is, there’s something in your app, or in the nested appex, that’s preventing the system from loading your appex.

              So can you please suggest what can be the possibilities (problems in packaging) that i have to check in my project.

              • Re: VPN is not connecting
                sjain7389 Level 1 Level 1 (0 points)

                Hi @eskimo,

                 

                I have checked my package but find nothing and i also create 2-3 times the extension target but getting the same issue again and again. Can you please help me in coming out from this problem or can you please suggest me any tutorial that i can follow for packaging. Thanks.

                  • Re: VPN is not connecting
                    eskimo Apple Staff Apple Staff (12,725 points)

                    You wrote:

                    I am trying by printing message in init method. But nothing is print on console.

                    and:

                    And i also check it by applying breakpoint and set Debug->Attach to Process

                    Neither of these are valid tests, alas.  NetworkExtension providers are started in a way that prevents Xcode from capturing stdout or from applying breakpoints that early.  I recommend that you re-test using system log.  That is:

                    1. Write an initialise like this:

                      class MyPacketTunnelProvider: NEPacketTunnelProvider {
                      
                      
                      override init() {
                          NSLog("qqq")
                          super.init()
                      }
                      
                      
                      … more code here …
                      }

                      where qqq is some unique string that’s easy to search for.

                    2. Launch Console on your Mac.

                    3. Select your iOS device on the left.

                    4. Make sure that Action > Include Info Messages and Action > Include Debug Message is set.

                    5. Start a search for your unique string.

                    6. Start your VPN.

                    IMPORTANT Using NSLog for this test is fine, but in the log term you should use the unified logging API.

                    Logging

                    Share and Enjoy

                    Quinn “The Eskimo!”
                    Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                    let myEmail = "eskimo" + "1" + "@apple.com"

                      • Re: VPN is not connecting
                        sjain7389 Level 1 Level 1 (0 points)

                        Hi,

                         

                        Thanks a lot eskimo. It helps me in resolving the problem.

                         

                        Can you please confirm me that how can we implement Split Tunnel with Packet Tunnel in my app with Swift 4.2.

                          • Re: VPN is not connecting
                            eskimo Apple Staff Apple Staff (12,725 points)

                            Can you please confirm me that how can we implement Split Tunnel with Packet Tunnel in my app with Swift 4.2.

                            A packet tunnel provider implements a full tunnel if it includes the default route (.defaultRoute()) in the includedRoutes property of the NEIPv4Settings and NEIPv6Settings settings objects it uses to configure the tunnel.  If it doesn’t include the default route, it creates a split tunnel, one that only gets the traffic destined for the specific routes it did include.

                            Share and Enjoy

                            Quinn “The Eskimo!”
                            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                            let myEmail = "eskimo" + "1" + "@apple.com"