ua_init Error 49
kannanmaran opened this issue · 8 comments
Hello!!
In iOS when connected to wifi ua_init method returning 49 Error code but it's working fine in mobile data on the same device. let me know if you need any debug print. Kindly help me with this.
as mentioned in this issue, I have copied the route.h file in iOS SDK also
OsType: iOS
Model: iPhone 8 Plus
OsVersion: 14.4
Baresip v 1.1.0
`net_debug_log(): 36 - net_debug_log = --- Network debug ---
Local IPv4: [E] en0|192.168.18.12
Local IPv6: [E] en0|fe80::ca9:5c79:32e4:bf56
net interfaces:
lo0: 127.0.0.1
lo0: ::1
lo0: fe80::1
pdp_ip1: fe80::14bb:55f4:4c6b:2898
pdp_ip1: 2409:4032:6d06:c3d4:9e:2384:da50:a9dc
pdp_ip1: 2409:4032:6d06:c3d4:7084:a35c:477:914e
pdp_ip0: 26.60.29.192
pdp_ip0: fe80::8c2:2fa7:36a4:3ea8
pdp_ip0: 2409:4072:6d00:80aa:805:c8ae:9efc:f302
pdp_ip0: 2409:4072:6d00:80aa:8dd0:98b0:71c:8dd
en0: fe80::ca9:5c79:32e4:bf56
en0: 192.168.18.12
awdl0: fe80::249e:93ff:fe0f:ed79
utun0: fe80::e914:9594:a020:2149
utun1: fe80::1aaa:fa59:469a:f52
ipsec2: fe80::fa95:eaff:fea3:a04c
ipsec2: 2409:4032:6d06:c3d4:9e:2384:da50:a9dc
ipsec3: fe80::fa95:eaff:fea3:a04c
ipsec3: 2409:4032:6d06:c3d4:9e:2384:da50:a9dc
llw0: fe80::249e:93ff:fe0f:ed79
DNS Servers from Config: (1)
0: 192.168.18.1:53
20:38:00 20-05-2021 void net_dns_debug_log(): 90 - net_dns_debug_log = DNS Servers from Config: (1)
0: 192.168.18.1:53
20:38:00 20-05-2021 void netif_debug_log(): 69 - net_if_debug -> net interfaces:
lo0: 127.0.0.1
lo0: ::1
lo0: fe80::1
pdp_ip1: fe80::14bb:55f4:4c6b:2898
pdp_ip1: 2409:4032:6d06:c3d4:9e:2384:da50:a9dc
pdp_ip1: 2409:4032:6d06:c3d4:7084:a35c:477:914e
pdp_ip0: 26.60.29.192
pdp_ip0: fe80::8c2:2fa7:36a4:3ea8
pdp_ip0: 2409:4072:6d00:80aa:805:c8ae:9efc:f302
pdp_ip0: 2409:4072:6d00:80aa:8dd0:98b0:71c:8dd
en0: fe80::ca9:5c79:32e4:bf56
en0: 192.168.18.12
awdl0: fe80::249e:93ff:fe0f:ed79
utun0: fe80::e914:9594:a020:2149
utun1: fe80::1aaa:fa59:469a:f52
ipsec2: fe80::fa95:eaff:fea3:a04c
ipsec2: 2409:4032:6d06:c3d4:9e:2384:da50:a9dc
ipsec3: fe80::fa95:eaff:fea3:a04c
ipsec3: 2409:4032:6d06:c3d4:9e:2384:da50:a9dc
llw0: fe80::249e:93ff:fe0f:ed79
20:38:00 20-05-2021 void netrt_debug_log(): 80 - net_rt_debug -> net routes:
Destination Next Hop Iface Type
0.0.0.0/0 192.168.18.1 en0
0.0.0.0/0 26.60.29.192 pdp_ip0
1.1.1.1/0 192.168.18.1 en0
5.39.68.205/0 192.168.18.1 en0
5.39.85.119/0 192.168.18.1 en0
17.57.12.11/0 192.168.18.1 en0
17.57.145.116/0 26.60.29.192 pdp_ip0
17.57.145.116/0 192.168.18.1 en0
17.57.145.117/0 192.168.18.1 en0
17.110.234.77/0 192.168.18.1 en0
17.242.2.32/0 192.168.18.1 en0
17.242.184.25/0 192.168.18.1 en0
17.248.162.4/0 192.168.18.1 en0
17.248.162.5/0 192.168.18.1 en0
17.248.162.6/0 192.168.18.1 en0
17.248.162.8/0 192.168.18.1 en0
17.248.162.38/0 192.168.18.1 en0
17.248.162.68/0 192.168.18.1 en0
17.248.162.71/0 192.168.18.1
void net_conf_debug(): 47 - net_conf_debug ->
SIP
sip_listen
sip_certificate
sip_cafile
sip_capath
sip_trans_def UDP
sip_verify_server no
sip_tos 160
Call
call_local_timeout 120
call_max_calls 4
call_hold_other_calls yes
Audio
audio_path /share/baresip
audio_player audiounit,nil
audio_source ,
audio_alert audiounit,nil
auplay_srate 48000
ausrc_srate 48000
auplay_channels 0
ausrc_channels 0
audio_level no
Video
video_source ,
#video_source avformat,rtmp://127.0.0.1/app/foo
video_display ,
video_size "640x480"
video_bitrate 1000000
video_fps 30.00
video_fullscreen yes
videnc_format yuv420p
AVT
rtp_tos 184
rtp_video_tos 136
rtp_ports 1024-49152
rtp_bandwidth 0-0
rtcp_mux no
jitter_buffer_type fixed
jitter_buffer_delay 5-10
jitter_buffer_wish 0
rtp_stats no
rtp_timeout 0 # in seconds
Network
net_interface
`
Thanks,
Kannan
can you please also share the full log ?
please lookup the error code 49 in the system documentation (iOS)
and see what is means.
can you please also share the full log?
please lookup the error code 49 in the system documentation (iOS)
and see what is means.
Hello!! @alfredh
Thanks for your reply.
it looks like a socket bind error as mentioned here I have tried the same app in a different network via wifi it was working fine. But this issue occurs in some wifi networks. and its works well in mobile data.
I have tried running baresip command from my terminal without any arguments (baresip) from my ubuntu machine on the same wifi network. got this below error.
baresip v1.1.0 Copyright (C) 2010 - 2021 Alfred E. Heggestad et al.
Local network address: IPv4=wlp2s0|192.168.100.6 IPv6=wlp2s0|fe80::734c:7f7f:5869:c919
tcp: sock_bind: bind: Invalid argument (af=10, [fe80::734c:7f7f:5869:c919]:0)
ua: SIP Transport failed: Invalid argument
ua: init failed (Invalid argument)
ua: stop all (forced=1)
I found that af=10 is set in the above log, so I executed the baresip command with -4 argument (baresip -4). then baresip started working fine in my ubuntu machine in the same wifi network. In iOS, I have defined the same for af=AF_INET but still no luck same error.
can you please specify which log do you want to debug?
below is the code am using
`-(void)startSip{
NSLog(@"Startig sip....");
//Private Lib path
NSArray *privatePaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *privateDocumentsPath = [privatePaths objectAtIndex:0];
(void)sys_coredump_set(true);
char start_error[64] = "";
int err;
struct le *le;
err = libre_init();
if(err){
NSLog(@"Error init libre %d", err);
strcpy(start_error, "init_libre");
[self stopBareSip:start_error];
return;
}
mod_init();
conf_path_set([privateDocumentsPath UTF8String]);
err = conf_configure();
if(err){
NSLog(@"Error to set config %d", err);
strcpy(start_error, "conf_configure");
[self stopBareSip:start_error];
return;
}
NSString *ipv4_addr_str = [Utils getIPAddress:true];
NSArray* ipv4_arr = [ipv4_addr_str componentsSeparatedByString:@"@"];
NSString *ipv4interface = ipv4_arr[0];
NSString *ipv4_addr = ipv4_arr[1];
NSString *ipv6_addr_str = [Utils getIPAddress:false];
NSArray* ipv6_arr = [ipv6_addr_str componentsSeparatedByString:@"@"];
NSString *ipv6interface = ipv6_arr[0];
NSString *ipv6_addr = ipv6_arr[1];
NSLog(@"ipv4Inter = %@ ipv4 = %@, ipv6Inter = %@ ipv6 = ", ipv4interface, ipv4_addr, ipv6interface, ipv6_addr);
/*
* Set the network interface before initializing the config
*/
if(![ipv4interface isEqualToString:@""]){
struct config *theconf = conf_config();
str_ncpy(theconf->net.ifname, [ipv4interface UTF8String], sizeof(theconf->net.ifname));
}
conf_config()->net.af = AF_INET;
err = baresip_init(conf_config());
if(err){
NSLog(@"Baresip init Error %d", err);
strcpy(start_error, "baresip_init");
[self stopBareSip:start_error];
return;
}
[self setNetworkAddress:ipv4_addr];
[self setNetworkAddress:ipv6_addr];
NSDictionary *dnsAdd = [self getDNSServers];
NSLog(@"dnsIpv4 = %@, dnsIpv6 = %@", [dnsAdd valueForKey:@"ipv4"], [dnsAdd valueForKey:@"ipv6"]);
log_level_set(0);
log_enable_debug(true);
net_debug_log();
net_dns_debug_log();
netif_debug_log();
netrt_debug_log();
net_conf_debug();
uag_enable_sip_trace(true);
play_set_path(baresip_player(), [privateDocumentsPath UTF8String]);
NSString* bua = [NSString stringWithFormat:@" baresip v %s (ARCH / %s)", BARESIP_VERSION, OS];
NSLog(@"bua = %@", bua);
err = ua_init([bua UTF8String], 1, 1, 1);
if(err){
**NSLog(@"Baresip ua_init Failed %d", err);**
strcpy(start_error, "ua_init");
[self stopBareSip:start_error];
return;
}
uag_set_exit_handler(ua_exit_handler, NULL);
err = uag_event_register(ua_event_handler, NULL);
if(err){
NSLog(@"Baresip uag_event_register Failed %d", err);
strcpy(start_error, "uag_event_register");
[self stopBareSip:start_error];
return;
}
err = conf_modules();
if (err) {
NSLog(@"Baresip conf_modules Failed %s", strerror(err));
strcpy(start_error, "conf_modules");
[self stopBareSip:start_error];
return;
}
char ua_buf[32];
struct ua *ua;
for (le = list_head(uag_list()); le != NULL; le = le->next) {
ua = le->data;
sprintf(ua_buf, "%lu", (unsigned long) ua);
// NSString *uas = [NSString stringWithFormat:@"%s", ua_buf];
NSLog(@"adding UA for AoR %s/%s", account_aor(ua_account(ua)), ua_buf);
ua_debug_log(ua);
}
err = mqueue_alloc(&mq, mqueue_handler, NULL);
if (err) {
NSLog(@"mqueue_alloc failed (%d)", err);
strcpy(start_error, "mqueue_alloc");
[self stopBareSip:start_error];
return;
}
for (le = list_head(uag_list()); le != NULL; le = le->next)
ua_print_status_log(le->data);
// Start the main loop.
NSLog(@"running main loop ...");
isLibStarted = YES;
err = re_main(signal_handler);
if (err) {
NSLog(@"stopping UAs due to error: (%d)", err);
ua_stop_all(true);
} else {
NSLog(@"main loop exit");
}
}
`
LOGS
19:30:20 22-05-2021 -[SIPManager startSip]:1530 -
Startig sip....
19:30:20 22-05-2021 -[SIPManager startSip]:1574 -
ipv4Inter = en0 ipv4 = 192.168.100.11, ipv6Inter = en0 ipv6 =
19:30:20 22-05-2021 -[SIPManager startSip]:1605 -
dnsIpv4 = dns_server 192.168.100.1:53
, dnsIpv6 =
19:30:20 22-05-2021 void net_debug_log(): 36 -
net_debug_log = --- Network debug ---
Local IPv4: [E] en0|192.168.100.11
Local IPv6: [.] en0|fe80::1867:a16b:1e57:256c
net interfaces:
lo0: 127.0.0.1
pdp_ip0: 25.70.16.172
en0: 192.168.100.11
DNS Servers from Config: (1)
0: 192.168.100.1:53
19:30:20 22-05-2021 void net_dns_debug_log(): 90 -
net_dns_debug_log = DNS Servers from Config: (1)
0: 192.168.100.1:53
19:30:20 22-05-2021 void netif_debug_log(): 69 -
net_if_debug -> net interfaces:
lo0: 127.0.0.1
lo0: ::1
lo0: fe80::1
pdp_ip0: 25.70.16.172
pdp_ip0: fe80::c8e:132b:97f6:52e3
pdp_ip0: 2409:4072:401:ea0b:109f:38ff:cf25:eeea
pdp_ip0: 2409:4072:401:ea0b:39dc:d4b1:b67a:7945
pdp_ip1: fe80::8d:4a2d:f47b:2feb
pdp_ip1: 2409:4032:409:fa32:149b:bd30:1308:7e28
pdp_ip1: 2409:4032:409:fa32:9ccd:8f0d:1d28:b899
en0: fe80::1867:a16b:1e57:256c
en0: 192.168.100.11
awdl0: fe80::5c7f:ff:feb3:6668
utun0: fe80::96ad:b920:d9db:579d
utun1: fe80::ca86:80cc:c016:645e
ipsec2: fe80::fa95:eaff:fea3:a04c
ipsec2: 2409:4032:409:fa32:149b:bd30:1308:7e28
ipsec3: fe80::fa95:eaff:fea3:a04c
ipsec3: 2409:4032:409:fa32:149b:bd30:1308:7e28
llw0: fe80::5c7f:ff:feb3:6668
19:30:20 22-05-2021 void netrt_debug_log(): 80 -
net_rt_debug -> net routes:
Destination Next Hop Iface Type
0.0.0.0/0 192.168.100.1 en0
0.0.0.0/0 25.70.16.172 pdp_ip0
17.57.12.16/0 192.168.100.1 en0
17.57.21.61/0 192.168.100.1 en0
17.57.145.116/0 192.168.100.1 en0
17.57.145.117/0 25.70.16.172 pdp_ip0
17.137.170.33/0 192.168.100.1 en0
17.242.184.25/0 192.168.100.1 en0
17.248.162.103/0 192.168.100.1 en0
17.248.162.135/0 192.168.100.1 en0
17.253.83.201/0 192.168.100.1 en0
17.253.83.203/0 192.168.100.1 en0
23.223.47.168/0 192.168.100.1 en0
31.13.79.54/0 192.168.100.1 en0
52.219.125.50/0 192.168.100.1 en0
104.86.189.105/0 192.168.100.1 en0
104.115.93.28/0 192.168.100.1 en0
104.115.93.155/0 192.168.100.1 en0
136.143.191.88/0 192.168.100.1
19:30:20 22-05-2021 void net_conf_debug(): 47 -
net_conf_debug ->
SIP
sip_listen
sip_certificate
sip_cafile
sip_capath
sip_trans_def UDP
sip_verify_server no
sip_tos 160
Call
call_local_timeout 120
call_max_calls 4
call_hold_other_calls yes
Audio
audio_path /share/baresip
audio_player audiounit,nil
audio_source ,
audio_alert audiounit,nil
auplay_srate 48000
ausrc_srate 48000
auplay_channels 0
ausrc_channels 0
audio_level no
Video
video_source ,
#video_source avformat,rtmp://127.0.0.1/app/foo
video_display ,
video_size "640x480"
video_bitrate 1000000
video_fps 30.00
video_fullscreen yes
videnc_format yuv420p
AVT
rtp_tos 184
rtp_video_tos 136
rtp_ports 1024-49152
rtp_bandwidth 0-0
rtcp_mux no
jitter_buffer_type fixed
jitter_buffer_delay 5-10
jitter_buffer_wish 0
rtp_stats no
rtp_timeout 0 # in seconds
Network
net_interface en0
19:30:20 22-05-2021 -[SIPManager startSip]:1622 -
bua = baresip v 1.1.0 (ARCH / ?)
19:30:20 22-05-2021 -[SIPManager startSip]:1625 -
Baresip ua_init Failed 49
19:30:20 22-05-2021 -[SIPManager stopBareSip:]:1696 -
closing ... ua_init
19:30:20 22-05-2021 -[SIPManager stopBareSip:]:1704 -
unloading modules ...
Thanks,
Kannan
Can you try the current libre version with: baresip/re@9a06d8c
Can you try the current libre version with: baresip/re@9a06d8c
Hell!! @sreimers
Thanks for your fix. this fix works fine in my ubuntu machine. but still, am facing the same issue in iOS. can you please help with this?
Can you try the current libre version with: baresip/re@9a06d8c
Hell!! @sreimers
Thanks for your fix. this fix works fine in my ubuntu machine. but still, am facing the same issue in iOS. can you please help with this?
Hello!!! @alfredh @sreimers
below is the error is getting from iOS can you help me with this?
tcp: sock_bind: bind: Can't assign requested address (af=30, [fe80::8f1:502d:f9a2:fc97]:0)
ua: SIP Transport failed: Can't assign requested address
ua: init failed (Can't assign requested address)
in iOS while setting ipv6 local address to net_set_address(baresip_network(), &temp_sa); only am getting the issue.
if is set ipv4 local address alone it's working fine.
this is the error am getting for ipv6.
** tcp: sock_bind: bind: Can't assign requested address (af=30, [fe80::8f1:502d:f9a2:fc97]:0)
is this error because their network is not supporting ipv6 or?
as of now, I have enabled ipv4 only. kindly suggest a better way to handle this.
Thanks,
Kannan
socket binding for a ipv6 link local address requires a scope id. you can prevent this like this (or something similar):
if (af == AF_INET6 && sa_is_linklocal(ip)) {
sa_init(ip, af); /* reset ipv6 address */
}
socket binding for a ipv6 link local address requires a scope id. you can prevent this like this (or something similar):
if (af == AF_INET6 && sa_is_linklocal(ip)) { sa_init(ip, af); /* reset ipv6 address */ }
Hello!! @sreimers
Thanks for your reply. ill try this and get back to you.