<html><body><span style="font-family:Verdana; color:#000000; font-size:10pt;"><div><br></div><div>I don't get it, if it is a web service, why do you use sockets? Isn't it just a matter of calling the web service using curl,and then wait for the response? what am I missing?<br></div><div><br></div><div>Christian Savinovich</div><div><strong><em>VoIP & Telephony Consultant</em></strong></div><div>646-982-3572</div><div> </div><div><br><br></div>
<blockquote id="replyBlockquote" webmail="1" style="border-left: 2px solid blue; margin-left: 8px; padding-left: 8px; font-size:10pt; color:black; font-family:verdana;">
<div id="wmQuoteWrapper">
-------- Original Message --------<br>
Subject: Re: [asterisk-users] problem to socket programming in AGI<br>
From: Justin Killen <<a href="mailto:jkillen@allamericanasphalt.com">jkillen@allamericanasphalt.com</a>><br>
Date: Mon, February 04, 2013 12:05 pm<br>
To: Asterisk Users Mailing List - Non-Commercial Discussion<br>
<<a href="mailto:asterisk-users@lists.digium.com">asterisk-users@lists.digium.com</a>><br>
<br>
<!--[if !mso]> <style>
#wmQuoteWrapper v\:* {behavior:url(#default#VML);}
#wmQuoteWrapper o\:* {behavior:url(#default#VML);}
#wmQuoteWrapper w\:* {behavior:url(#default#VML);}
#wmQuoteWrapper .shape {behavior:url(#default#VML);}
</style> <![endif]--><o:smarttagtype namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"> <!--[if !mso]> <style>
#wmQuoteWrapper st1\:* {behavior:url(#default#ieooui) }
</style> <![endif]--> <style>
#wmQuoteWrapper /* Font Definitions */ @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;}
#wmQuoteWrapper /* Style Definitions */ p.MsoNormal, #wmQuoteWrapper li.MsoNormal, #wmQuoteWrapper div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman";}
#wmQuoteWrapper a:link, #wmQuoteWrapper span.MsoHyperlink {color:blue; text-decoration:underline;}
#wmQuoteWrapper a:visited, #wmQuoteWrapper span.MsoHyperlinkFollowed {color:purple; text-decoration:underline;}
#wmQuoteWrapper code {font-family:"Courier New";}
#wmQuoteWrapper span.EmailStyle17 {mso-style-type:personal-reply; font-family:Arial; color:navy;}
#wmQuoteWrapper @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in;}
#wmQuoteWrapper div.Section1 {page:Section1;}
</style> <div class="Section1"> <div class="MsoNormal" style="font-size:12pt;"><font color="navy" face="Arial" size="2"><span style="font-size: 10.0pt;font-family:Arial;color:navy">You are correct, this is not an asterisk question. What I would suggest would be to run your script outside of asterisk and debug the connection. Looking at the php doc page for fsockopen (<a target="_blank" href="http://php.net/manual/en/function.fsockopen.php">http://php.net/manual/en/function.fsockopen.php</a>), I see this example:<o:p></o:p></span></font></div> <div class="MsoNormal" style="font-size:12pt;"><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB"><?php</span></font></code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; font-family:"Courier New";color:#0000BB"><br> <code><font face="Courier New">$fp </font></code></span></font><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">= </span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">fsockopen</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">(</span></font></code><code><font color="#dd0000" face="Courier New" size="2"><span style="font-size:10.0pt;color:#DD0000">"www.example.com"</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">, </span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">80</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">, </span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">$errno</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">, </span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">$errstr</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">, </span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">30</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">);</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;font-family:"Courier New"; color:#007700"><br> <code><font face="Courier New">if (!</font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$fp</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">) {</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; font-family:"Courier New";color:#007700"><br> <code><font face="Courier New"> echo </font></code></span></font><code><font color="#dd0000" face="Courier New" size="2"><span style="font-size:10.0pt; color:#DD0000">"</span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">$errstr</span></font></code><code><font color="#dd0000" face="Courier New" size="2"><span style="font-size:10.0pt; color:#DD0000"> (</span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">$errno</span></font></code><code><font color="#dd0000" face="Courier New" size="2"><span style="font-size:10.0pt; color:#DD0000">)<br />\n"</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">;</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;font-family:"Courier New"; color:#007700"><br> <code><font face="Courier New">} else {</font></code><br> <code><font face="Courier New"> </font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$out </span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">= </span></font></code><code><font color="#dd0000" face="Courier New" size="2"><span style="font-size:10.0pt; color:#DD0000">"GET / HTTP/1.1\r\n"</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">;</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;font-family:"Courier New"; color:#007700"><br> <code><font face="Courier New"> </font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$out </span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">.= </span></font></code><code><font color="#dd0000" face="Courier New" size="2"><span style="font-size:10.0pt; color:#DD0000">"Host: <a href="http://www.example.com">www.example.com</a>\r\n"</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">;</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;font-family:"Courier New"; color:#007700"><br> <code><font face="Courier New"> </font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$out </span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">.= </span></font></code><code><font color="#dd0000" face="Courier New" size="2"><span style="font-size:10.0pt; color:#DD0000">"Connection: Close\r\n\r\n"</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; color:#007700">;</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;font-family:"Courier New"; color:#007700"><br> <code><font face="Courier New"> </font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">fwrite</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">(</span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$fp</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">, </span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$out</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">);</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; font-family:"Courier New";color:#007700"><br> <code><font face="Courier New"> while (!</font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">feof</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">(</span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$fp</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">)) {</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; font-family:"Courier New";color:#007700"><br> <code><font face="Courier New"> echo </font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">fgets</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">(</span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$fp</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">, </span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">128</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">);</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; font-family:"Courier New";color:#007700"><br> <code><font face="Courier New"> }</font></code><br> <code><font face="Courier New"> </font></code></span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">fclose</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">(</span></font></code><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt; color:#0000BB">$fp</span></font></code><code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt;color:#007700">);</span></font></code><font color="#007700" face="Courier New" size="2"><span style="font-size:10.0pt; font-family:"Courier New";color:#007700"><br> <code><font face="Courier New">}</font></code><br> </span></font><code><font color="#0000bb" face="Courier New" size="2"><span style="font-size:10.0pt;color:#0000BB">?></span></font></code><code><font color="black" face="Courier New" size="2"><span style="font-size:10.0pt;color:black"> </span></font></code><o:p></o:p></div> <div class="MsoNormal" style="font-size:12pt;"><font color="navy" face="Arial" size="2"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><o:p> </o:p></span></font></div> <div class="MsoNormal" style="font-size:12pt;"><font color="navy" face="Arial" size="2"><span style="font-size: 10.0pt;font-family:Arial;color:navy">I would first try running that (put in your host and port) and see what the error string coming back is.<o:p></o:p></span></font></div> <div class="MsoNormal" style="font-size:12pt;"><font color="navy" face="Arial" size="2"><span style="font-size: 10.0pt;font-family:Arial;color:navy"><o:p> </o:p></span></font></div> <div> <div> <div class="MsoNormal" style="font-size:12pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><font color="navy" face="Arial" size="2"><span style="font-size:10.0pt;font-family:Arial; color:navy">-Justin<o:p></o:p></span></font></div> </div> </div> <div> <div class="MsoNormal" style="font-size:12pt;text-align:center" align="center"><font face="Times New Roman" size="3"><span style="font-size:12.0pt"> <hr tabindex="-1" align="center" size="2" width="100%"> </span></font></div> <div class="MsoNormal" style="font-size:12pt;"><b><font face="Tahoma" size="2"><span style="font-size:10.0pt; font-family:Tahoma;font-weight:bold">From:</span></font></b><font face="Tahoma" size="2"><span style="font-size:10.0pt;font-family:Tahoma"> <a href="mailto:asterisk-users-bounces@lists.digium.com">asterisk-users-bounces@lists.digium.com</a> [<a href="mailto:asterisk-users-bounces@lists.digium.com">mailto:asterisk-users-bounces@lists.digium.com</a>] <b><span style="font-weight: bold">On Behalf Of </span></b>Muhammad<br> <b><span style="font-weight:bold">Sent:</span></b> Monday, February 04, 2013 5:07 AM<br> <b><span style="font-weight:bold">To:</span></b> <st1:personname w:st="on">Asterisk Users Mailing List - Non-Commercial Discussion</st1:personname><br> <b><span style="font-weight:bold">Subject:</span></b> [asterisk-users] problem to socket programming in AGI</span></font><o:p></o:p></div> </div> <div class="MsoNormal" style="font-size:12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12.0pt"><o:p> </o:p></span></font></div> <div> <div class="MsoNormal" style="font-size:12pt;"><font face="Times New Roman" size="3"><span style="font-size: 12.0pt">Hi,<br> I know maybe this question is not related to asterisk, but I want to make XML RPC web service to other http server.<br> I have elastix system. it is https and problem is source not destination server. In xml rpc we have fsockopen connection to connect destination server(xml rpc server). It return me connect error(0).<br> <br> what is the problem. is this related to elastix(asterisk) server?<o:p></o:p></span></font></div> </div> </div> <hr>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
<a href="http://www.asterisk.org/hello">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
<a href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a>
</o:smarttagtype></div>
</blockquote></span></body></html>