<html><head></head><body><div class="ydpc7c5274dyahoo-style-wrap" style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 13px;"><div></div>
        <div>Digging into this a bit deeper, I now understand the exact problem.</div><div><br></div><div>The issue is the difference in newlines between sdp_get output and the JSON format.</div><div><br></div><div><span>sdp_get returns the SDP with unix newline characters i.e. <span><span style="color: rgb(34, 34, 34); font-family: monospace, monospace; font-size: 14px;">\r\n.</span></span></span><br></div><div><span><br></span></div><div><span>However JSON won't accept unix newlines and requires a single line output with literal \r\n instead (i.e. escaped).</span></div><div><span><br></span></div><div><span>So now I'm having to write the SDP into an external file using exec_msg, manipulate it with <span>awk -v RS='\r?\n' -v ORS='\\r\\n' '1' </span>and then bring it back into Kamailio. Not nice and also not yet working correctly yet.</span></div><div><span><br></span></div><div><span>If there was a function within the JANSSON module to take a multi-line input (like the SDP) and convert it into a single line with literal \r\n characters ready for posting in a JSON message then that would make life much easier.</span></div><div><br></div><div><span><span><br></span></span></div><div><span><br></span></div><div><span><br></span></div><div><span><br></span></div><div><span><br></span></div><div><br></div>
        
        </div><div id="yahoo_quoted_6215081544" class="yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                
                <div>
                    On Sunday, 21 April 2019, 19:15:22 BST, David Dean <just_bytesize@yahoo.co.uk> wrote:
                </div>
                <div><br></div>
                <div><br></div>
                <div><div id="yiv3769503626"><div><div class="yiv3769503626yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div>I'm trying to send an SDP from a SIP client to Janus using JSON over HTTP.</div><div><br></div><div>The problem is that Janus is erroring on the SDP content with the following error:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px;"><div><span>JANUS HTTP: Get SDP for echo plugin: {#012   "janus": "error",#012   "error": {#012      "code": 454,#012      "reason": "JSON error: on line 9: control character 0xd near '\"v=0'"#012   }#012} Result code 200</span></div></blockquote><div><span><br></span></div><div><span>I tried using <span>{s.escape.common} to escape any quotations, commas etc but it doesn't appear to replace the control characters with newlines.</span></span></div><div><span><span><br>Any suggestions on how best to remove these control characters so that Janus will accept the SDP over JSON?</span></span></div><div><span><span><br></span></span></div><div><span><span>Here is the relevant section of kamailio.cfg:</span></span></div><div><span><span><br></span></span></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px;"><div><span><span><span><div># HTTP: Request SDP for echo test plugin</div></span></span></span></div><div><span><span><span><div>                sdp_get("$avp(sdp)");</div></span></span></span></div><div><span><span><span><div><br></div></span></span></span></div><div><span><span><span><div>                $var(res) = http_connect("janus", "/janus/$var(JANUS-ID)/$var(ECHO-ID)", "application/json", "{</div></span></span></span></div><div><span><span><span><div>        \"janus\" : \"message\",</div></span></span></span></div><div><span><span><span><div>        \"transaction\" : \"testtesttest99\",</div></span></span></span></div><div><span><span><span><div>        \"body\" : {</div></span></span></span></div><div><span><span><span><div>                \"audio\" : true</div></span></span></span></div><div><span><span><span><div>        },</div></span></span></span></div><div><span><span><span><div>        \"jsep\" : {</div></span></span></span></div><div><span><span><span><div>                \"type\" : \"offer\",</div></span></span></span></div><div><span><span><span><div>                \"sdp\" : \"$(avp(sdp){s.escape.common})\"</div></span></span></span></div><div><span><span><span><div>        }</div></span></span></span></div><div><span><span><span><div>}", "$avp(janus-pluginsession)");</div></span></span></span></div><div><span><span><span><div>                xlog("L_INFO", "JANUS HTTP: Get SDP for echo plugin: $avp(janus-pluginsession) Result code $var(res)\n");</div></span></span></span></div><div><span><span><br></span></span></div></blockquote><div><span><span><br></span></span></div></div></div></div></div>
            </div>
        </div></body></html>