How to Register With DNS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm Developing an VOIP app in iOS, I'm trying to register with domain or IP, Its working fine. While trying to connect with DNS to my SIP server, it giving errors. At my code part it write as below.

//Here dns is DNS domain name like example.com

  dns = [[NSUserDefaults standardUserDefaults] stringForKey: @"dnsServer"];

  array = [dns componentsSeparatedByString:@","];

  NSEnumerator *enumerator = [array objectEnumerator];

  NSString *anObject;

  unsigned i;

  char line[128];

  Boolean result;

  CFHostRef hostRef;

  NSString *hostname = dns;

  NSMutableArray *tempDNS = [[NSMutableArray alloc] init];

  CFArrayRef addresses = NULL;

  hostRef = CFHostCreateWithName(kCFAllocatorDefault, (__bridge CFStringRef)hostname);

  if (hostRef) {

    result = CFHostStartInfoResolution(hostRef, kCFHostAddresses, NULL);

    if (result == TRUE) {

        addresses = CFHostGetAddressing(hostRef, &result);

        for(int i = 0; i < CFArrayGetCount(addresses); i++){

            struct sockaddr_in* remoteAddr;

            CFDataRef saData = (CFDataRef)CFArrayGetValueAtIndex(addresses, i);

            remoteAddr = (struct sockaddr_in*)CFDataGetBytePtr(saData);

            if(remoteAddr != NULL){

                // Extract the ip address

                //const char *strIP41 = inet_ntoa(remoteAddr->sin_addr);

                NSString *strDNS =[NSString stringWithCString:inet_ntoa(remoteAddr->sin_addr) encoding:NSASCIIStringEncoding];

//Our DNS returns 2 name server  

                NSLog(@"RESOLVED %d:<%@>", i, strDNS);

                [tempDNS addObject:strDNS];//here I'm adding IP address to an array.

            }

        }

    }

  } 

  while (anObject = [enumerator nextObject])

  {

    NSMutableString *mutableStr = [anObject mutableCopy];

    CFStringTrimWhitespace((CFMutableStringRef)mutableStr);

    srv = [mutableStr UTF8String];

    if (srv && strlen(srv))

    {

     if (app_config->cfg.nameserver_count==PJ_ARRAY_SIZE(app_config->cfg.nameserver))

      {

        PJ_LOG(1,(THIS_FILE, "Error: too many DNS servers"));

        [mutableStr release];

        break;

      }

      for (i=0; i<app_config->cfg.nameserver_count; ++i) {

          pj_ansi_sprintf(line, "--nameserver %.*s\n",(int)app_config->cfg.nameserver[i].slen,app_config->cfg.nameserver[i].ptr);

//          pj_strcat2(&cfg, line);

      }

      pj_strdup2_with_null(app_config->pool, &(app_config->cfg.nameserver[app_config->cfg.nameserver_count++]), srv);

    }

      [mutableStr release];

  }

I'm getting response like below. Any one please guide me, How to work with DNS. Sample code would appreciate.

2016-07-28 10:12:29.899 MYApp[266:39854] granted

2016-07-28 10:12:29.904 MYApp[266:39854] -[Reachability isReachableViaWiFi] (632) 

Reachability Flags: -R -------

10:12:31.842 os_core_unix.c !pjlib 2.3 for POSIX initialized

10:12:31.848 sip_endpoint.c  .Creating endpoint instance...

10:12:31.851          pjlib  .select() I/O Queue created (0x17a75f34)

10:12:31.852 sip_endpoint.c  .Module "mod-msg-print" registered

10:12:31.852 sip_transport.  .Transport manager created.

10:12:31.852   pjsua_core.c  .PJSUA state changed: NULL --> CREATED

2016-07-28 10:12:31.856 MYApp[266:39854] RESOLVED 0:<52.86.229.130>

2016-07-28 10:12:31.856 MYApp[266:39854] RESOLVED 1:<52.73.47.94>

10:12:37.822 sip_endpoint.c  .Module "mod-pjsua-log" registered

10:12:37.826   pjsua_core.c  .Nameserver vabsys.com added

10:12:37.826 sip_endpoint.c  .Module "mod-tsx-layer" registered

10:12:37.826 sip_endpoint.c  .Module "mod-stateful-util" registered

10:12:37.826 sip_endpoint.c  .Module "mod-ua" registered

10:12:37.826 sip_endpoint.c  .Module "mod-100rel" registered

10:12:37.826 sip_endpoint.c  .Module "mod-pjsua" registered

10:12:37.827 sip_endpoint.c  .Module "mod-invite" registered

10:12:37.871 coreaudio_dev.  .. dev_id 0: iPhone IO device  (in=1, out=1) 8000Hz

10:12:37.871 coreaudio_dev.  ..core audio initialized

10:12:37.871          pjlib  ..select() I/O Queue created (0x17a79214)

10:12:37.901 sip_endpoint.c  .Module "mod-evsub" registered

10:12:37.901 sip_endpoint.c  .Module "mod-presence" registered

10:12:37.901 sip_endpoint.c  .Module "mod-mwi" registered

10:12:37.901 sip_endpoint.c  .Module "mod-refer" registered

10:12:37.901 sip_endpoint.c  .Module "mod-pjsua-pres" registered

10:12:37.901 sip_endpoint.c  .Module "mod-pjsua-im" registered

10:12:37.901 sip_endpoint.c  .Module "mod-pjsua-options" registered

10:12:37.901   pjsua_core.c  .1 SIP worker threads created

10:12:37.901   pjsua_core.c  .pjsua version 2.3 for  initialized

10:12:37.901   pjsua_core.c  .PJSUA state changed: CREATED --> INIT

10:12:37.903   pjsua_core.c  SIP UDP socket reachable at 192.168.1.55:5060

10:12:37.903  udp0x17a80200  SIP UDP transport started, published address is 192.168.1.55:5060

10:12:37.904    tcplis:5060  SIP TCP listener ready for incoming connections at 192.168.1.55:5060

10:12:37.904   tcplis:49851  SIP TCP listener ready for incoming connections at fe80::186d:af8f:4693:2b3d:49851

10:12:37.905   pjsua_core.c  SIP UDP socket reachable at fe80::186d:af8f:4693:2b3d:50425

10:12:37.905 udpv60x1824be0  SIP UDP IPv6 transport started, published address is [fe80::186d:af8f:4693:2b3d]:50425

10:12:37.905   pjsua_core.c  PJSUA state changed: INIT --> STARTING

10:12:37.905 sip_endpoint.c  .Module "mod-unsolicited-mwi" registered

10:12:37.905   pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING

2016-07-28 10:12:43.307 MYApp[266:39854] There IS internet connection

10:12:43.308    pjsua_acc.c  Adding account: id=sip:3my2000@xxxxxxxxxx;transport=tcp;hide

10:12:43.308    pjsua_acc.c  .Account sip:3my2000@xxxxxxxxxx;transport=tcp;hide added with id 0

10:12:43.308    pjsua_acc.c  .Acc 0: setting registration..

10:12:43.308    pjsua_acc.c  ..Warning: cannot use source TCP/TLS socket address for Contact when nameserver is configured.

10:12:43.309    pjsua_acc.c  ..Warning: cannot use source TCP/TLS socket address for Contact when nameserver is configured.

10:12:43.309     resolver.c  ...Transmitting 38 bytes to NS 0 (52.86.229.130:53): DNS SRV query for _sip._tcp.vabsys.com: Success

10:12:43.309    pjsua_acc.c  ..Acc 0: Registration sent

2016-07-28 10:12:43.312 MYApp[266:39854] applicationDidBecomeActive

10:12:45.311     resolver.c !Re-transmitting 38 bytes to NS 0 (52.86.229.130:53): DNS SRV query for _sip._tcp.vabsys.com: Success

10:12:47.311     resolver.c  Re-transmitting 38 bytes to NS 0 (52.86.229.130:53): DNS SRV query for _sip._tcp.vabsys.com: Success

10:12:49.311     resolver.c  Re-transmitting 38 bytes to NS 0 (52.86.229.130:53): DNS SRV query for _sip._tcp.vabsys.com: Success

10:12:51.313     resolver.c  Re-transmitting 38 bytes to NS 0 (52.86.229.130:53): DNS SRV query for _sip._tcp.vabsys.com: Success

10:12:53.313 _sip._tcp.vabs  DNS SRV resolution failed for _sip._tcp.vabsys.com: Operation timed out (PJ_ETIMEDOUT)

10:12:53.313 _sip._tcp.vabs  DNS SRV resolution failed for _sip._tcp.vabsys.com, trying resolving A record for vabsys.com

10:12:53.314     resolver.c  Transmitting 28 bytes to NS 0 (52.86.229.130:53): DNS A query for vabsys.com: Success

10:12:55.314     resolver.c  Re-transmitting 28 bytes to NS 0 (52.86.229.130:53): DNS A query for vabsys.com: Success

10:12:57.315     resolver.c  Error transmitting request: No working DNS nameserver (PJLIB_UTIL_EDNSNOWORKINGNS)

10:12:57.315 _sip._tcp.vabs  DNS A record resolution failed: Operation timed out (PJ_ETIMEDOUT)

10:12:57.315  sip_resolve.c  DNS A record resolution failed: Operation timed out (PJ_ETIMEDOUT)

10:12:57.315  tsx0x17a87664  Failed to send Request msg REGISTER/cseq=27562 (tdta0x18252000)! err=70009 (Operation timed out (PJ_ETIMEDOUT))

10:12:57.315    pjsua_acc.c  ..SIP registration failed, status=503 (Operation timed out (PJ_ETIMEDOUT))

10:12:57.315    pjsua_acc.c  ..Scheduling re-registration retry for acc 0 in 0 seconds..

2016-07-28 10:12:57.316 MYApp[266:39945] Status changed acc 0 Service Unavailable (503)

10:12:57.318    pjsua_acc.c !Deleting account 0..

10:12:57.319    pjsua_acc.c  .Account id 0 deleted

10:12:57.319   pjsua_core.c  Shutting down, flags=0...

10:12:57.319   pjsua_core.c  PJSUA state changed: RUNNING --> CLOSING

10:12:57.325   pjsua_call.c  .Hangup all calls..

10:12:57.325  pjsua_media.c  .Call 0: deinitializing media..

10:12:57.325  pjsua_media.c  .Call 1: deinitializing media..

10:12:57.325  pjsua_media.c  .Call 2: deinitializing media..

10:12:57.325  pjsua_media.c  .Call 3: deinitializing media..

10:12:57.325   pjsua_pres.c  .Shutting down presence..

10:12:58.326   pjsua_core.c  .Destroying...

10:12:58.326  pjsua_media.c  .Shutting down media..

10:12:58.440 sip_transactio  .Stopping transaction layer module

10:12:58.440 sip_transactio  .Stopped transaction layer module

10:12:58.440 sip_endpoint.c  .Module "mod-unsolicited-mwi" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-pjsua-options" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-pjsua-im" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-pjsua-pres" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-pjsua" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-stateful-util" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-refer" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-mwi" unregistered

10:12:58.440 sip_endpoint.c  .Module "mod-presence" unregistered

10:12:58.441 sip_endpoint.c  .Module "mod-evsub" unregistered

10:12:58.441 sip_endpoint.c  .Module "mod-invite" unregistered

10:12:58.441 sip_endpoint.c  .Module "mod-100rel" unregistered

10:12:58.441 sip_endpoint.c  .Module "mod-ua" unregistered

10:12:58.441 sip_transactio  .Transaction layer module destroyed

10:12:58.441 sip_endpoint.c  .Module "mod-tsx-layer" unregistered

10:12:58.441 sip_endpoint.c  .Module "mod-msg-print" unregistered

10:12:58.441 sip_endpoint.c  .Module "mod-pjsua-log" unregistered

10:12:58.444    tcplis:5060  .SIP TCP listener destroyed

10:12:58.445   tcplis:49851  .SIP TCP listener destroyed

10:12:58.445 sip_endpoint.c  .Endpoint 0x17a75864 destroyed

10:12:58.445   pjsua_core.c  .PJSUA state changed: CLOSING --> NULL

10:12:58.445   pjsua_core.c  .PJSUA destroyed...

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux