PJSUA2: Contact header uri length limit

二次信任 提交于 2019-12-25 01:39:02

问题


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?

来源:https://stackoverflow.com/questions/56507170/pjsua2-contact-header-uri-length-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!