On 3/6/08, Julian Cable <julian.cable at yahoo.com> wrote: > Hi Benny, > > sorry, I wasn't clear - pjsua wasn't running when the interfaces changed. > > I think I understand at least part of the problem now though. pjsua will use > the ip address returned by gethostbyname in the SIP URL when creating a new > request BUT when responding to a request, it will send it to where it came > from. I think that's not exactly right. For transaction, yes, the response will be sent to the source address of the packet if ";rport" parameter is present in top most Via header. That's fine, there's no problem there. The problem is with calculating the address to be put in Contact header of incoming INVITE. > So A sends to B and the url has been typed in so its sip:localhost:5062 and > B replies with 200 OK to the address the message came from which is > localhost:5062 and puts its own url in, which is sip:192.168.2.195:5062 > which it got from gethostbyname. A then sends the ACK to > sip:192.168.2.195:5062, not to sip:localhost:5062 but 192.168.2.195 doesn't > work because the interface with this IP address is down. So A is left in the > CONNECTED state and B is left in the CONNECTING state. Yes, that's the problem. > Its really hard in a dynamic IP environment with wired and wireless ports to > keep gethostbyname always meaningful, especially when only the loopback > interface is operational (e.g. when I'm on the train). Several applications > complain if you add the hostname to the loopback address in /etc/hosts. Well if you only have loopback interface running, why would you want to run VoIP at all? > It would be better if pjsua worked out its IP address for its URL from the > list of working interfaces, not from gethostbyname. > That frankly I'm not sure. The problem with this is if there are multiple working interfaces, which one do you pick? It depends on the routing table to the other endpoint of course, but pjsip currently doesn't do this. So lacking this, it seems that picking the address from gethostbyname() is better, as you should make sure that you always put a good entry there. Having said that, pjsip does have a fallback mechanism to query the list of working interfaces, should gethostbyname() returns loopback address. pjsip (pjsua-lib) would work better if only you configure STUN and ICE, and if you register to a public SIP server. In this configuration, the IP address would be detected automatically from the REGISTER response, and pjsua-lib even has some support to handle IP address change. cheers, -benny > Ekiga seems to do something like this - it doesn't like running AT ALL if > only the loopback interface is up. > > Julian