title: iOS 8 VPN - Network Extension - error in __connection_block_invoke_2
body: <p>I am using below code to configure VPN</p>
  
  <pre><code>- (void)setupConfiguration
  {
      NEVPNManager *manager = [NEVPNManager sharedManager];
      int status = manager.connection.status;
  
      if (status == NEVPNStatusConnected) {
          [manager.connection stopVPNTunnel];
      }
      else
      {
          [manager loadFromPreferencesWithCompletionHandler:^(NSError *error)
          {
              if (error) {
                  NSLog(@"Load config failed [%@]", error.localizedDescription);
                  return;
              }
  
              NEVPNProtocolIPSec *p = (NEVPNProtocolIPSec *)manager.protocol;
              if (!p) {
                  p = [[NEVPNProtocolIPSec alloc] init];
              }
  
              NSString *username = [Username];
              NSString *url = @"Server URL";
              p.username = username;
              p.serverAddress = url;
  
              p.passwordReference = [Password from Keychain];
              p.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;
              p.sharedSecretReference = [Shared secret from Keychain];
              //p.localIdentifier = @"";
              //p.remoteIdentifier = @"";
  
              p.disconnectOnSleep = NO;
              p.useExtendedAuthentication = YES;
  
              [manager setProtocol:p];
              [manager setOnDemandEnabled:NO];
              [manager setLocalizedDescription:@"VIT VPN"];
              NSLog(@"Connection desciption: %@", manager.localizedDescription);
              NSLog(@"VPN status:  %li", (long)manager.connection.status);
  
              [manager saveToPreferencesWithCompletionHandler:^(NSError *error) {
                  if(error) {
                      NSLog(@"Save error: %@", error);
                  } else {
                      NSLog(@"Saved!");
                  }
              }];
          }];
      }
  }
  </code></pre>
  
  <p>I am calling this method on <code>viewDidLoad</code>.
  <br>I am getting this error in log - <code>"error in __connection_block_invoke_2: Connection interrupted"</code> when user navigates from device VPN settings to our app after completing profile installation. After that, when I try to connect to VPN server, nothing happens.
  <br>Can anyone please help me with this, why I am getting this error?</p>
  
  <p>Note:- I have followed these tutorials:<br>
  1. <a href="http://ramezanpour.net/post/2014/08/03/configure-and-manage-vpn-connections-programmatically-in-ios-8/" rel="nofollow">http://ramezanpour.net/post/2014/08/03/configure-and-manage-vpn-connections-programmatically-in-ios-8/</a><br>2. <a href="https://disqus.com/home/discussion/ramezanpour/configure_and_manage_vpn_connections_programmatically_in_ios_8/newest/" rel="nofollow">https://disqus.com/home/discussion/ramezanpour/configure_and_manage_vpn_connections_programmatically_in_ios_8/newest/</a></p>