问题
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