crissmoldovan / tisip

Titanium PJSIP
MIT License
6 stars 0 forks source link

Cannot register on SIP server using tisip.register() #1

Open loffler opened 7 years ago

loffler commented 7 years ago

Hi,

I am not able to register on my Asterisk server using tisip.register(). I am using this piece of code:

var accountId = tisip.register({
    account: "2000",
    domain: "192.168.1.38",
    realm: "192.168.1.38",
    username: "2000",
        password: "1234",
    });

To investigate the problem, I monitored the network traffic on the Asterisk machine using tcpdump. I could see that some data were actually received on network interface, but in Asterisk's console nothing was logged. In the upper part of attached image there is network dump of registration using tisip and below is registration using Linphone client. You can see that the pisip request doesn't even contain any word "REGISTER". wireshark

Could you please help me with this issue?

crissmoldovan commented 7 years ago

Hi, can you please check if any registration error event is emited?

it might be the case that no transport has been initialised.

try doing something like this:

var events = [
    'REGISTRATION.CONNECTING', 
    'REGISTRATION.DISCONNECTING', 
    'REGISTRATION.CONNECTED', 
    'REGISTRATION.DISCONNECTED', 
    'REGISTRATION.OFFLINE', 
    'REGISTRATION.INVALID', 
    'MWI', 
    'MESSAGE.INCOMING', 
    'MESSAGE.STATUS', 
    'CALL.INCOMING', 
    'CALL.READY', 
    'CALL.CALLING', 
    'CALL.CONNECTING', 
    'CALL.CONNECTED', 
    'CALL.DISCONNECTED',
    'PUSH.REGISTER.SUCCESS',
    'PUSH.REGISTER.FAILED',
    'PUSH.RECEIVED',
    'SPEAKER.YES',
    'SPEAKER.NO',
    'MUTED.YES',
    'MUTED.NO'
];

events.forEach(function(event){
    tisip.addEventListener(event, function(event){
        console.log("SIP EVT:", event);
    });
});

var accountId = tisip.register({
    account: [ACCOUNT],
    domain: [IP OR DOMAIN],
    realm: [IP OR DOMAIN],
    username: [USERNAME],
    password: [PASSWORD]
});

let me know, hot it goes.

crissmoldovan commented 7 years ago

updated to code, and now it's all up to date. IPV6 is also enabled (apple rejects apps that do not work on ipv6 only networks).

loffler commented 7 years ago

Still no luck. Here are the events that got fired on registration:

[INFO] :   TI got REGISTRATION.CONNECTING with args:
[INFO] :   {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.CONNECTING";
[INFO] :   }
[INFO] :   SIP EVT: {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.CONNECTING";
[INFO] :   }
[INFO] :   registered: 0
[INFO] :   REG STATE NOTIF: status: INVALID for account 0
[INFO] :   TI got REGISTRATION.INVALID with args:
[INFO] :   {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.INVALID";
[INFO] :   }
[INFO] :   SIP EVT: {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.INVALID";
[INFO] :   }
[INFO] :   REG STATE NOTIF: status: CONNECTING for account 0
[INFO] :   TI got REGISTRATION.CONNECTING with args:
[INFO] :   {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.CONNECTING";
[INFO] :   }
[INFO] :   SIP EVT: {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.CONNECTING";
[INFO] :   }
[INFO] :   REG STATE NOTIF: status: INVALID for account 0
[INFO] :   TI got REGISTRATION.INVALID with args:
[INFO] :   {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.INVALID";
[INFO] :   }
[INFO] :   SIP EVT: {
[INFO] :       accountId = 0;
[INFO] :       bubbles = 1;
[INFO] :       cancelBubble = 0;
[INFO] :       source = "[object ComCrissmoldovanTisipModule]";
[INFO] :       type = "REGISTRATION.INVALID";
[INFO] :   }

By the way, here are some additional informations on my environment:

crissmoldovan commented 7 years ago

hey, just to make sure all is linked correctly, please download the archive from the dist folder and install that one. Although since you are receiving events it shows pjsip is initiated correctly.

can you please try switching your server to accept udp connections and see if it works?

loffler commented 7 years ago

Thank you for your time. I tried it it with that archive too. I assume my server is already set to accept UDP connections, as I can register on it using Linphone, which is configured to use UDP only.

However, as I already mentioned in my first post, the application only sends few TCP packets which do not contain any REGISTER flag, so i think the problem is not in the server, but somewhere in my app.

If you could take a quick look, here is my whole source directory.

crissmoldovan commented 7 years ago

no worries :)

so, let's try this: switch your server to TCP, i think it's the easy win. Try to set Linphone to connect via TCP, and if it works, give it a go with your app.

I don't see anything wrong with your code.

loffler commented 7 years ago

hooray! the registration works now with TCP, but I can not make any calls. Nevertheless, is there any simple way to switch tisip to use UDP? Also, do I have always to specify correct realm for registration? It didn't work for me without having it set.

loffler commented 7 years ago

Despite having only little clue about how this module works, I assume I will have to modify its source code. May it help to modify lines 236, 284 and 355 in iphone/Classes/PjSIPProxy.m to contain transport=udp? I'm barely sure this will be enough, but will try it as soon as I get to my SIP machine.

crissmoldovan commented 7 years ago

hey buddy, sorry it took me this long. Looks like i forgot that thing hardcoded. Apologies. I've rebuild it with the udp transport. It's a dirty fix so you can do your thing :)

If you diff on the PjSIPProxy.m file you'll see 2 changes. Normally the trasport should be sent as a param of the register function. If you feel doing it, go ahead and send a pull request.

Unfortunately i'm not actively maintaining this module as I switched to ReactNative.

Happy to assist if anything is needed.

Cheers

loffler commented 7 years ago

cool, now I can register via UDP. Many thanks for that patch. :1st_place_medal: When I first saw the commit history, I already knew this project is no longer maintained. The more I am pleasantly surprised with your helpfulness. :)

Now, if you don't mind, hopefully the last question; when I want to place a call, my app crashes and Asterisk console gives me this output: WARNING[28360][C-0000000d]: channel.c:5353 set_format: Unable to find a codec translation path from (nothing) to (gsm)