<p>I asynchronously report registration info to application server.</p>
<pre><code>loadmodule "jansson.so"
loadmodule "http_async_client.so"
loadmodule "http_client.so"
modparam("http_client", "httpredirect", 0)
modparam("http_client", "useragent", "E-CSCF")
modparam("http_client", "maxdatasize", 64535)
modparam("http_client", "connection_timeout", 2)
modparam("http_client", "tlsversion", 6)
modparam("http_client", "keep_connections", 1)
modparam("http_client", "httpcon", "lisendpoint=>https://example.com/LIS")

# Sending regisration info to LIS server
route[SEND_REGISTRATION_TO_LIS] {
        xlog("L_ALERT","DEBUG: Sending registration info to LIS for $fu\n");
        $var(payload)='{}';
        $var(json_request)='{}';
        jansson_set("string", "call_id", $ci, "$var(payload)");
        jansson_set("integer", "msg_timestamp", $Ts, "$var(payload)");
        jansson_set("integer", "expires", $xavp(ulrcd[0]=>expires), "$var(payload)");
        jansson_set("string", "network_address", $si, "$var(payload)");
        jansson_set("integer", "network_port", $sp, "$var(payload)");
        jansson_set("string", "from", $fu, "$var(payload)");
        jansson_set("string", "user_agent", $ua, "$var(payload)");
        jansson_set("string", "contact", $ct, "$var(payload)");
        jansson_set("obj", "registration_update", "$var(payload)", "$var(json_request)");
        $http_req(suspend) = 0;
        $http_req(hdr) = "Content-Type: application/json";
        $http_req(body) = $var(json_request);

        http_async_query("LIS_URL", "LIS_REPLY");
}

route[LIS_REPLY] {
    if ($http_ok) {
        xlog("L_INFO", "route[HTTP_REPLY]: status $http_rs\n");
        xlog("L_INFO", "route[HTTP_REPLY]: body   $http_rb\n");
    } else {
        xlog("L_INFO", "route[HTTP_REPLY]: error  $http_err)\n");
    }
}
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/1794#issuecomment-452397776">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZVeFmqW-gq29XhvZy8B50zQwvCpRks5vBN_igaJpZM4Z1vUS">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZeQfbExspBOri4gKWfx47liVXEOdks5vBN_igaJpZM4Z1vUS.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@sergey-safarov in #1794: I asynchronously report registration info to application server.\r\n```\r\nloadmodule \"jansson.so\"\r\nloadmodule \"http_async_client.so\"\r\nloadmodule \"http_client.so\"\r\nmodparam(\"http_client\", \"httpredirect\", 0)\r\nmodparam(\"http_client\", \"useragent\", \"E-CSCF\")\r\nmodparam(\"http_client\", \"maxdatasize\", 64535)\r\nmodparam(\"http_client\", \"connection_timeout\", 2)\r\nmodparam(\"http_client\", \"tlsversion\", 6)\r\nmodparam(\"http_client\", \"keep_connections\", 1)\r\nmodparam(\"http_client\", \"httpcon\", \"lisendpoint=\u003ehttps://example.com/LIS\")\r\n\r\n# Sending regisration info to LIS server\r\nroute[SEND_REGISTRATION_TO_LIS] {\r\n        xlog(\"L_ALERT\",\"DEBUG: Sending registration info to LIS for $fu\\n\");\r\n        $var(payload)='{}';\r\n        $var(json_request)='{}';\r\n        jansson_set(\"string\", \"call_id\", $ci, \"$var(payload)\");\r\n        jansson_set(\"integer\", \"msg_timestamp\", $Ts, \"$var(payload)\");\r\n        jansson_set(\"integer\", \"expires\", $xavp(ulrcd[0]=\u003eexpires), \"$var(payload)\");\r\n        jansson_set(\"string\", \"network_address\", $si, \"$var(payload)\");\r\n        jansson_set(\"integer\", \"network_port\", $sp, \"$var(payload)\");\r\n        jansson_set(\"string\", \"from\", $fu, \"$var(payload)\");\r\n        jansson_set(\"string\", \"user_agent\", $ua, \"$var(payload)\");\r\n        jansson_set(\"string\", \"contact\", $ct, \"$var(payload)\");\r\n        jansson_set(\"obj\", \"registration_update\", \"$var(payload)\", \"$var(json_request)\");\r\n        $http_req(suspend) = 0;\r\n        $http_req(hdr) = \"Content-Type: application/json\";\r\n        $http_req(body) = $var(json_request);\r\n\r\n        http_async_query(\"LIS_URL\", \"LIS_REPLY\");\r\n}\r\n\r\nroute[LIS_REPLY] {\r\n    if ($http_ok) {\r\n        xlog(\"L_INFO\", \"route[HTTP_REPLY]: status $http_rs\\n\");\r\n        xlog(\"L_INFO\", \"route[HTTP_REPLY]: body   $http_rb\\n\");\r\n    } else {\r\n        xlog(\"L_INFO\", \"route[HTTP_REPLY]: error  $http_err)\\n\");\r\n    }\r\n}\r\n```"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1794#issuecomment-452397776"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1794#issuecomment-452397776",
"url": "https://github.com/kamailio/kamailio/issues/1794#issuecomment-452397776",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>