Stefano Baronio wrote:

>Hello all,
>       I am using kannel with a php application (some web pages) and somethimes
>messages are not sent due to this error:
>2002-07-08 16:58:13 [2] DEBUG: HTTP: Creating HTTPClient for `127.0.0.1'.
>2002-07-08 16:58:16 [1] DEBUG: HTTP: Destroying HTTPClient area 0x80dc000.
>2002-07-08 16:58:16 [1] DEBUG: HTTP: Destroying HTTPClient for `127.0.0.1'.
>
This is not an error - it's what the boxes say when someone connects to 
them using HTTP. it's a valid debug log with no error.

>
>My application makes a socket connection to kannel and does something like
>this:
>$fp = fsockopen($SmsServer, 13013);
>sleep(1); /* One second delay, otherwise it never works on normally run  */
>socket_set_blocking($fp,1); /* wait for response on fgets()*/
>
Why ? you are looping on feof() and shouldn't set the socket to blocking 
mode.

>if ($fp)
>       { // Send HTTP request
>       $SmsDataUrl =
>"?username=$SmsUser&password=$SmsPass&to=".$Dest[$i]['GSM']."&text=$msg";
>       $header = "GET /cgi-bin/sendsms".$SmsDataUrl." HTTP/1.0\r\nAccept:
>*/*\r\n\r\n";
>       fputs($fp, $header);
>       // Get the response
>       $response="";
>       while(!feof($fp))
>       $response .= fgets($fp, 128);
>       fclose($fp);
>       }
>else {print "Error connecting";}
>
>The GET command is correctly passed as:
>GET /cgi-bin/sendsms?username=test&password=test&to=123456."&text=Test
>as seen with tcpdump.
>
>It all works when I run the script in debug mode (step by step), but when I
>run the script normally, I receive that error from kannel and $fp result to
>be EOF (closed).
>
>I cannot figure out what is going on. It could be an apache/php problem, but
>it does not give to me any error.
>
>Thanks for any help.
>
>Stefano Baronio
>
>
>  
>
Generaly speaking, I don't think you should use socket programming in 
PHP for HTTP connections - PHP has a good HTTP infrastructure using the 
fopen() and file() function calls. these calls will allow you to easily 
do GET calls to Kannel and other HTTP applications. If you need the 
ability to do POST calls, then PHP has an extension to link with the 
excellent cURL library which does all kinds of HTTP magic.

I've had many problems with PHP socket programming and HTTP, and moving 
to a cURL based implementation or using the internal file wrappers for 
HTTP solved it for me.

-- 
Oded Arbel
m-Wise mobile solutions




Reply via email to