MayamaTakeshi / sip-lab

A node module that helps to write SIP functional tests
3 stars 2 forks source link

Failure to resolve transport for incoming call when names are used in case of ip addresses #97

Closed MayamaTakeshi closed 8 months ago

MayamaTakeshi commented 8 months ago

I tested by creating transport this way:

    const t1 = sip.transport.create({address: "localhost"})
    const t2 = sip.transport.create({address: "localhost"})

Then when making a call from t1 to t2 I go this error:

build_transport_tag_from_pjsip_transport address=127.0.0.1
on_rx_request INVITE transport_tag=udp:127.0.0.1:5061
could not resolve transport id=-1

This is of course because localhost became 127.0.0.1 and so there was no match because the tag was set as "udp:localhost:5061".

Obs: this will be particularly problematic with services in a docker compose setup where the services talk to each other using the service names.

MayamaTakeshi commented 8 months ago

We would need to change this code:

void build_transport_tag(char *dest, const char *type, const char *address,
                         int port) {
  sprintf(dest, "%s:%s:%d", type, address, port);
}

to check if address is a name and if yes, dns-resolve it.

But in pjsip, DNS resolution is done async: https://docs.pjsip.org/en/latest/api/generated/pjlib_util/group/group__PJ__DNS__SRV__RESOLVER.html

which will not work well for us (we immediately create transports and make calls). So let's see if there is some other alternative.