Version 1 (modified by bennylp, 11 years ago) (diff)


Using SIP TCP Transport

Table of Contents

  1. Enabling TCP support
  2. Sending Initial Requests
  3. Contact Header
  4. Subsequent Requests
  5. Additional Info about Registration

Enabling TCP support

First you must instantiate SIP TCP transport in your application. The TCP transport is enabled by default on pjsua so you can skip this test if you're using pjsua.

Sending Initial Requests

PJSIP only sends the request with TCP if the destination URI contains ";transport=tcp" parameter. Adding this parameter can be accomplished in two ways:

  1. the most convenient way is to add a route-set entry (with proxy or outbound proxy setting) containing URI with TCP transport. This way all initial requests will be sent with TCP via the proxy, and we don't need to change the URI for the registrar and all buddies in the buddy list. Sample code:
    pjsua_acc_config acc_cfg;
    acc_cfg.proxy[acc_cfg.proxy_cnt++] = pj_str(";transport=tcp");
  2. if you don't want to configure route set entry, then you must add ";transport=tcp" parameter to all outgoing URIs (the registrar URI, the buddy URI, the target URI when making call, the target URI when sending MESSAGE, etc.). For example, to make outgoing call with TCP:
    pj_str_t dst = pj_str(";transport=tcp");
    status = pjsua_call_make_call(acc_id, &dst, NULL, NULL, NULL, NULL);

Contact Header

With PJSUA-LIB, when making or receiving calls with TCP, the local Contact header will automatically be adjusted to use the TCP transport.

Subsequent Requests

Subsequent requests means subsequent request that is sent within the call (dialog), for example UPDATE, BYE, re-INVITE to hold the call, and so on.

Additional Info about Registration

The client registration session also will keep the TCP connection active throughout the registration session, and server may send inbound requests using this TCP connection if it wants to.