Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"event : nua_r_register status : 503 phrase : DNS Error" in Android Client #265

Open
mano-kotdev opened this issue Aug 5, 2024 · 0 comments

Comments

@mano-kotdev
Copy link

I have cross compiled sofia-sip for Android and trying to register a sip server but getting 503 DNS error. I have followed the reference documentation. Sharing the code snippets and logs below:

typedef struct context context;
#define NUA_MAGIC_T struct context

typedef union operation operation;
#define NUA_HMAGIC_T  operation


#include <sofia-sip/nua.h>
#include <sofia-sip/sip_util.h.>
#include <sofia-sip/su_log.h>
#include <sofia-sip/sres_sip.h>
#include <sofia-sip/sresolv.h>
#include <sofia-sip/su_alloc.h>

struct context {
    su_home_t home[1];
    su_root_t *root;
    sres_resolver_t *sres;
    sres_query_t *s_query;
    nua_t *nua;
};

typedef union operation {
    nua_handle_t *handle;
    struct {
        nua_handle_t *handle;
    } call;

    struct {
        nua_handle_t *handle;
    } subscription;
} operation;

Starting sofia-sip and registering

std::string proxy = "sip:sip.linphone.org";
std::string username = "someuser";
context s_ctx[1] = {{{{(sizeof s_ctx)}}}};
operation *op = (operation *) su_zalloc(s_ctx->home, (sizeof *op));

su_init();
su_log_init(su_log_default);
su_log_set_level(su_log_default, 9);
su_log_redirect(su_log_default, custom_logger, stdout);

const char *resolvConfContents = env->GetStringUTFChars(resolv_content, NULL);

std::string tempFilePath = "/data/data/com.honeywell.healthcare.systevo/files/resolv.conf";
FILE *tempFile = fopen(tempFilePath.c_str(), "w");
if (tempFile) {
fputs(resolvConfContents, tempFile);
fclose(tempFile);
}

su_home_init(s_ctx->home);
s_ctx->root = su_root_create(&s_ctx);
if (s_ctx->root == NULL) {
__android_log_print(ANDROID_LOG_DEBUG, "Sofia-SIP", "%s", "Failed to create root");
return -1;
}

s_ctx->nua = nua_create(s_ctx->root, nua_callback, s_ctx, TAG_NULL());
if (s_ctx->nua == NULL) {
__android_log_print(ANDROID_LOG_DEBUG, "Sofia-SIP", "%s", "Failed to create nua");
return -1;
}

op->handle = nua_handle(s_ctx->nua, op, TAG_NULL());

s_ctx->sres = sres_resolver_create(s_ctx->root, tempFilePath.c_str(), TAG_END());
if (s_ctx->sres == NULL) {
__android_log_print(ANDROID_LOG_DEBUG, "Sofia-SIP", "%s", "Failed to create resolver");
return -1;
}

nua_set_params(s_ctx->nua,
                   NUTAG_MEDIA_ENABLE(1),
                   SIPTAG_ALLOW_STR(
                           "INVITE, SUBSCRIBE, ACK, BYE, CANCEL, OPTIONS, PRACK, MESSAGE, UPDATE, NOTIFY, INFO"),
                   NUTAG_USER_AGENT("UserAgent/1.0"),
                   NUTAG_ENABLEMESSAGE(1),
                   NUTAG_ENABLEINVITE(1),
                   NUTAG_AUTOALERT(0),
                   NUTAG_SESSION_TIMER(0),
                   NUTAG_AUTOANSWER(0),
                   NUTAG_EARLY_MEDIA(0),
                   NUTAG_EARLY_ANSWER(0),
                   NUTAG_AUTOACK(1),
                   NTATAG_UDP_MTU(1700),
                   TAG_NULL()
);
su_root_step(s_ctx->root, 1000);

nua_set_params(
            s_ctx->nua,
            NUTAG_PROXY(proxy.c_str()),
            NUTAG_REGISTRAR(proxy.c_str()),
            NUTAG_M_DISPLAY(username.c_str()),
            SIPTAG_FROM_STR("sip:[email protected]"),
            TAG_END()
);
su_root_step(s_ctx->root, 1000);

nua_register(
            op->handle,
            NUTAG_REGISTRAR(proxy.c_str()),
            NUTAG_AUTH_CACHE(nua_auth_cache_challenged),
            SIPTAG_EXPIRES_STR("4000"),
            TAG_END()
);
su_root_step(s_ctx->root, 4000);

log output

su_epoll_port.c:541 su_epoll_port_create() su_port_create(0x7644588280): epoll_create() => 0: OK
su_socket_port.c:88 su_socket_port_init() su_socket_port_init(0x7644588280, 0x75eb4ece08) called
su_pthread_port.c:73 su_pthread_port_init() su_pthread_port_init(0x7644588280, 0x75eb4ece08) called
nua.c:138 nua_create() nua: nua_create: entering
su_epoll_port.c:541 su_epoll_port_create() su_port_create(0x76490b1380): epoll_create() => 0: OK
su_socket_port.c:88 su_socket_port_init() su_socket_port_init(0x76490b1380, 0x75eb4ece08) called
su_pthread_port.c:73 su_pthread_port_init() su_pthread_port_init(0x76490b1380, 0x75eb4ece08) called
nua_stack.c:128 nua_stack_init() nua: nua_stack_init: entering
nua_params.c:484 nua_stack_set_params() nua: nua_stack_set_params: entering
soa.c:229 soa_create() soa_create("default", 0x76490212c0, 0x76490cde00) called
soa.c:403 soa_set_params() soa_set_params(static::0x764909a000, ...) called
soa.c:403 soa_set_params() soa_set_params(static::0x764909a000, ...) called
nta.c:978 nta_agent_create() nta_agent_create: initialized hash tables
nta.c:985 nta_agent_create() nta_agent_create: initialized transports
nta.c:991 nta_agent_create() nta_agent_create: initialized random identifiers
nta.c:997 nta_agent_create() nta_agent_create: initialized timer
nta.c:1007 nta_agent_create() nta_agent_create: initialized resolver
tport.c:498 tport_tcreate() tport_create(): 0x76490ba700
nta.c:2335 agent_create_master_transport() nta: master transport created
tport.c:1626 tport_bind_server() tport_bind_server(0x76490ba700) to */*:5060/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for udp
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x764904f300
tport.c:732 tport_listen() tport_listen(0x76490ba700): bind(pf=2 udp/[192.168.29.52]:5060): Address already in use
nta.c:2285 nta_agent_add_tport() nta: bind(*:5060;transport=*): Address already in use
tport.c:1626 tport_bind_server() tport_bind_server(0x76490ba700) to */*:*/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for udp
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x764904f300
tport.c:756 tport_listen() tport_listen(0x764904f300): listening at udp/192.168.29.52:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for tcp
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x764904f800
tport.c:756 tport_listen() tport_listen(0x764904f800): listening at tcp/192.168.29.52:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for ws
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x76490baa00
tport.c:756 tport_listen() tport_listen(0x76490baa00): listening at ws/192.168.29.52:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for udp
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x764904ff80
tport.c:756 tport_listen() tport_listen(0x764904ff80): listening at udp/[::1]:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for tcp
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x7649050480
tport.c:756 tport_listen() tport_listen(0x7649050480): listening at tcp/[::1]:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for ws
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x76490bad00
tport.c:756 tport_listen() tport_listen(0x76490bad00): listening at ws/[::1]:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for udp
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x7649050c00
tport.c:756 tport_listen() tport_listen(0x7649050c00): listening at udp/127.0.0.1:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for tcp
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x7649051100
tport.c:756 tport_listen() tport_listen(0x7649051100): listening at tcp/127.0.0.1:46445/sip
tport.c:1698 tport_bind_server() tport_bind_server(0x76490ba700): calling tport_listen for ws
tport.c:626 tport_alloc_primary() tport_alloc_primary(0x76490ba700): new primary tport 0x7649113000
tport.c:756 tport_listen() tport_listen(0x7649113000): listening at ws/127.0.0.1:46445/sip
nta.c:2294 nta_agent_add_tport() nta: bound to (*:*;transport=*)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/udp 192.168.29.52:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/tcp 192.168.29.52:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/ws 192.168.29.52:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/udp [::1]:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/tcp [::1]:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/ws [::1]:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/udp 127.0.0.1:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/tcp 127.0.0.1:46445 (sip)
nta.c:2437 agent_init_via() nta: agent_init_via: SIP/2.0/ws 127.0.0.1:46445 (sip)
nta.c:2303 nta_agent_add_tport() nta: Via fields initialized
nta.c:2311 nta_agent_add_tport() nta: Contact header created
stun.c:406 stun_is_requested() stun_is_requested: entering.
nua_register.c:1470 nua_registration_from_via() nua_register: Adding contact URL '192.168.29.52' to list.
nua_register.c:1470 nua_registration_from_via() nua_register: Adding contact URL '192.168.29.52' to list.
nua_register.c:1435 nua_registration_from_via() nua_register: ignoring contact candidate [::1]:46445.
nua_register.c:1435 nua_registration_from_via() nua_register: ignoring contact candidate [::1]:46445.
nua_register.c:1435 nua_registration_from_via() nua_register: ignoring contact candidate 127.0.0.1:46445.
nua_register.c:1435 nua_registration_from_via() nua_register: ignoring contact candidate 127.0.0.1:46445.
nua_common.c:108 nh_create_handle() nua: nh_create_handle: entering
nua.c:574 nua_set_params() nua: nua_set_params: entering
nua_stack.c:559 nua_signal() nua(0x0): sent signal r_set_params
nua_params.c:484 nua_stack_set_params() nua: nua_stack_set_params: entering
soa.c:403 soa_set_params() soa_set_params(static::0x764909a000, ...) called
nua_stack.c:389 nua_application_event() nua: nua_application_event: entering
event : nua_r_set_params status : 200 phrase : OK
nua.c:1157 nua_unref_user() nua: nua_unref_user: entering
nua_stack.c:559 nua_signal() nua(0x0): sent signal r_unref
nua.c:574 nua_set_params() nua: nua_set_params: entering
nua_stack.c:559 nua_signal() nua(0x0): sent signal r_set_params
nua_params.c:484 nua_stack_set_params() nua: nua_stack_set_params: entering
soa.c:403 soa_set_params() soa_set_params(static::0x764909a000, ...) called
nua_stack.c:389 nua_application_event() nua: nua_application_event: entering
event : nua_r_set_params status : 200 phrase : OK
nua.c:1157 nua_unref_user() nua: nua_unref_user: entering
nua_stack.c:559 nua_signal() nua(0x0): sent signal r_unref
nua.c:621 nua_register() nua: nua_register: entering
nua_stack.c:559 nua_signal() nua(0x76445d8840): sent signal r_register
nua_params.c:484 nua_stack_set_params() nua: nua_stack_set_params: entering
soa.c:280 soa_clone() soa_clone(static::0x764909a000, 0x76490212c0, 0x76445d8840) called
soa.c:403 soa_set_params() soa_set_params(static::0x764909a200, ...) called
soa.c:403 soa_set_params() soa_set_params(static::0x764909a200, ...) called
nua_dialog.c:338 nua_dialog_usage_add() nua(0x76445d8840): adding register usage
nta.c:4497 nta_leg_tcreate() nta_leg_tcreate(0x764901e500)
nta.c:2716 nta_tpn_by_url() nta: selecting scheme sip
sres_cache.c:272 sres_cache_get() sres_cache_get(0x76490214c0, NAPTR, "sip.linphone.org.") called
nta.c:10537 outgoing_query_naptr() nta: for "sip.linphone.org" query "sip.linphone.org" NAPTR
sres.c:981 sres_query() sres_query(0x76490435e0, 0x76490a7f00, NAPTR, "sip.linphone.org") called
sres.c:2743 sres_send_dns_query() sres_send_dns_query(0x76490435e0, 0x76490b1a80) called
sresolv.c:190 sres_sofia_update() sres_sofia_update(0x764901e380, 102, -1)
sres.c:2832 sres_send_dns_query() sres_send_dns_query(0x76490435e0, 0x76490b1a80) id=13974 NAPTR sip.linphone.org (to [127.0.0.1]:53)
sres.c:3273 sres_resolver_error() sres_resolver_error(0x76490435e0, 102) called
sres.c:3430 sres_resolver_report_error() sres: network error 111 (Connection refused) from 127.0.0.1 by icmp type=3 code=3 reported by 127.0.0.1
sres.c:3073 sres_resend_dns_query() sres_resend_dns_query(0x76490435e0, 0x76490b1a80, error) called
sres.c:3000 sres_query_report_error() sres(q=0x76490b1a80): reporting error NETWORK_ERR for NAPTR sip.linphone.org
sres_cache.c:272 sres_cache_get() sres_cache_get(0x76490214c0, SRV, "_sip._udp.sip.linphone.org.") called
nta.c:10738 outgoing_query_srv() nta: for "sip.linphone.org" query "_sip._udp.sip.linphone.org" SRV
sres.c:981 sres_query() sres_query(0x76490435e0, 0x76490a7f00, SRV, "_sip._udp.sip.linphone.org") called
sres.c:2743 sres_send_dns_query() sres_send_dns_query(0x76490435e0, 0x76490b1b60) called
sres.c:2832 sres_send_dns_query() sres_send_dns_query(0x76490435e0, 0x76490b1b60) id=13975 SRV _sip._udp.sip.linphone.org (to [127.0.0.1]:53)
sres.c:3073 sres_resend_dns_query() sres_resend_dns_query(0x76490435e0, 0x76490b1b60, error) called
sres.c:3000 sres_query_report_error() sres(q=0x76490b1b60): reporting error NETWORK_ERR for SRV _sip._udp.sip.linphone.org
sres_cache.c:272 sres_cache_get() sres_cache_get(0x76490214c0, AAAA, "sip.linphone.org.") called
nta.c:10862 outgoing_query_aaaa() nta: for "sip.linphone.org" query "sip.linphone.org" AAAA
sres.c:981 sres_query() sres_query(0x76490435e0, 0x76490a7f00, AAAA, "sip.linphone.org") called
sres.c:2743 sres_send_dns_query() sres_send_dns_query(0x76490435e0, 0x76490b1a80) called
sres.c:2822 sres_send_dns_query() sres_send_dns_query(): sendto: Connection refused
nta.c:1371 set_timeout() nta: timer set to 32000 ms
nta.c:1369 set_timeout() nta: timer shortened to 5000 ms
nua_dialog.c:397 nua_dialog_usage_remove_at() nua(0x76445d8840): removing register usage
nua_stack.c:389 nua_application_event() nua: nua_application_event: entering
nta.c:4550 nta_leg_destroy() nta_leg_destroy(0x764901e500)
event : nua_r_register status : 503 phrase : DNS Error
nua.c:1170 nua_handle_unref_user() nua nua_handle_unref_user(0x76445d8840): entering
sres.c:3273 sres_resolver_error() sres_resolver_error(0x76490435e0, 102) called
nua_stack.c:559 nua_signal() nua(0x76445d8840): sent signal r_handle_unref
nua.c:1157 nua_unref_user() nua: nua_unref_user: entering
sres.c:3430 sres_resolver_report_error() sres: network error 111 (Connection refused) from 127.0.0.1 by icmp type=3 code=3 reported by 127.0.0.1
nua_stack.c:559 nua_signal() nua(0x0): sent signal r_unref
0
nta.c:9234 outgoing_timer_dk() nta: timer K fired, terminate REGISTER (86864955)
nta.c:8906 outgoing_reclaim_queued() outgoing_reclaim_all(0x0, 0x0, 0x764589ea68)
nta.c:9053 _nta_outgoing_timer() nta_outgoing_timer: 0/0 resent, 0/0 tout, 1/1 term, 1/1 free
nta.c:1310 agent_timer() nta: timer not set

but if i do the query separately with custom resolver i created using resolv.conf file, i am getting answers

const char *domain = "sip.linphone.org";
    s_ctx->s_query = sres_query(s_ctx->sres, process_dns_response, NULL, sres_type_a,
                                     domain);
    if (s_ctx->s_query == NULL) {
        __android_log_print(ANDROID_LOG_DEBUG, "Sofia-SIP", "%s", "Failed to create query");
        return -1;
    }
    su_root_step(s_ctx->root, 4000);

log output

sres.c:981 sres_query() sres_query(0x75ee86a640, 0x0, A, "sip.linphone.org") called
sres.c:2743 sres_send_dns_query() sres_send_dns_query(0x75ee86a640, 0x7644588360) called
sresolv.c:190 sres_sofia_update() sres_sofia_update(0x75ee86f400, 101, -1)
sres.c:2832 sres_send_dns_query() sres_send_dns_query(0x75ee86a640, 0x7644588360) id=22348 A sip.linphone.org (to [8.8.8.8]:53)
sres.c:3479 sres_resolver_receive() sres_resolver_receive(0x75ee86a640, 101) called
sres.c:3795 sres_create_record() ANSWER RR received sip.linphone.org. A IN 8028 rdlen=4

somehow the sofia-sip is not using the custom resolver i created but it is using the default one, your help is much appreciated here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant