0

I'm building an android VOIP application with push notifications support, based on PJSUA2.

I need to send the push notification (FCM) token to the server (Asterisk in my case) as contact uri parameter, so that I can retrieve it with a script from the server and send notification to wake up client before sending an incoming call request.

I put the parameters in the contact uri parameters with

acfg.getSipConfig().setContactUriParams(buildParams(contactParameters));

contactParams is a HashMap<String, String> with parameters name and value, while buildParams is the following method:

private String buildParams(Map<String, String> params) {
    StringBuilder builder = new StringBuilder();
    for (String k : params.keySet()) {
        builder.append(';');
        builder.append(k);
        String v = params.get(k);
        if (v != null && v.trim().length() > 0) {
            builder.append("=\"");
            builder.append(v);
            builder.append('\"');
        }
    }
    return builder.toString();
}

without FCM parameters everything works well, but

  • building the contact uri with the following parameters ;pn-provider="fcm";pn-tok="LONG FCM TOKEN" makes the calls hangup after 32 seconds (see question PJSUA2 Android - Incoming calls drop after 32 seconds)
  • removing ;pn-provider="fcm" works
  • sending just a portion of the token works (in pn-tok, together with the pn-provider parameter)

I thought it may be a "invalid characters issue", but it actually seems to be a "max length issue".

Is there a Contact header max length or a URI max length for Contact header? If yes, is it a PJSIP limit or a SIP limit?

Ivano85
  • 98
  • 1
  • 11
  • How did you work around this issue? I am working on a react native app using pjsip lib and when creating an account with the long `pn-tok` raises an exception. Let me know. Thanks – user380692 Oct 16 '19 at 07:33
  • I didn't work around this issue in a stable way yet. At the moment I applied a patch to increase the maximum contact uri length to 512 or 768 (https://github.com/VoiSmart/pjsip-android-builder), but it only seems to work if I only add the "pn-tok" parameter (without other pn-* parameters). If I just add the pn-provider parameter, the issue comes again. I think there is some other issue in the app or server side, but I didn't find it yet. I obtained this behaviour with both PJSUA 2.8 and 2.9 in conjunction with Asterisk 13. – Ivano85 Oct 17 '19 at 11:50

0 Answers0