Ben Curl en RETURNTRANSFER seçeneği ile sporadik bir sorun haline çalıştırıyorum. Ben bunu neden benim kod gözden kaçan bir şey varsa emin değilim, ya da sadece iyi belgelenmiş ve değilse ben RETURNTRANSFER işleyişini habersiz.
I am using curl (via php) to send xml data via POST to an external listener. If successful, the listener responds and returns the same xml, with one or two fields populated that I sent through empty.
eg. <Status />
becomes <Status>
Accepted</Status>
. A rough size of the full xml POST - [upload_content_length] => 1414. A unique ID (generated on my side) is sent, if the listener receives a duplicate ID, it declines the xml data and responds with a plain text error message.
Bu zamanın% 99.9 çalışır.
Curl kodu:
$header[] = "Content-Type: text/xml";
$header[] = "Content-length: ".strlen($post_string);
$x = curl_init("https://xyz.com");
curl_setopt($x, CURLOPT_HEADER, 0);
curl_setopt($x, CURLOPT_HTTPHEADER, $header);
curl_setopt($x, CURLOPT_POST, 1);
curl_setopt($x, CURLOPT_POSTFIELDS,$xmldata);
curl_setopt($x, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($x, CURLOPT_REFERER, "https://mypage.com");
curl_setopt($x, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($x, CURLOPT_PORT, 443);
curl_setopt($x, CURLOPT_SSL_VERIFYPEER, 0); //to allow self-signed SSL cert
curl_setopt($x, CURLOPT_SSL_VERIFYHOST, 0); //to allow self-signed SSL cert
curl_setopt($x, CURLOPT_TIMEOUT, 30);
curl_setopt($x, CURLOPT_FORBID_REUSE, TRUE);
curl_setopt($x, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($x, CURLOPT_BUFFERSIZE, 64000);
curl_setopt($x, CURLOPT_VERBOSE, 1);
$listenerresponse = curl_exec($x);
$info = curl_getinfo($x);
curl_close($x);
Geçenlerde yinelenen kimlikleri üzerinde dinleyici hatalar hataları toplayıp edilmiştir.
Benim günlükleri bu kadar zaman çizelgesi göstermek ::
benzersiz id kıvırmak POST "12345678"
dinleyici 2010-10-13 17:27:59 at "yinelenen ID" yanıt
Dinleyici "Kabul" 2010-10-13 17:28:06 yanıt
Initially I though a previous ID had been cached somehow and was being sent erroneously, but this is not the case. The listener receives the correct ID. The listener logs show it the other way around, with a slightly differing chronology:
Dinleyici 2010-10-13 17:27:48 at "Kabul" yanıt
Dinleyici 2010-10-13 17:27:58 at "yinelenen ID" yanıt
From my understanding, I would expect the curl thread to wait for the response, and not send another request. Am I right in presuming that the problem is network related - possible packets dropping/something similar? Any suggestions on how to prevent this happening would be most appreciated. Ideally I would like curl to send and wait for the full response before sending off another request... Is there an option to specify this? Please help :-)
İlginiz için teşekkür ederiz.
S.