2

Here are my code samples:

function xmlPostStore($post_xml, $url, $port) {
    $ch = curl_init(); // initialize curl handle
    curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
    curl_setopt($ch, CURLOPT_FAILONERROR, 1); // Fail on errors
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
    curl_setopt($ch, CURLOPT_PORT, $port); //Set the port number
    curl_setopt($ch, CURLOPT_TIMEOUT, 15); // times out after 15s
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_xml); // add POST fields
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

what i'm sending:

$XML = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
        <SendConfig>
            <Request>
                <key>passphrase</key>
            </Request>
        </SendConfig>";

$reply = xmlPostStore($XML, "http://www.urlhere.com/test.php", "80");

test.php is just a simple XML return:

echo "<?xml version='1.0' encoding='utf-8'?>
<response>
    <config>
        <test>it works</test>
    </config>
</response>";

When I test this on one server, it works 100% of the time. I receive a response and there's no issues.

When I test it on our main server, it returns back nothing, most of the time, about 98% of the time it's blank. Without any code changes, it will randomly work and randomly stop. I'm stumped.

4
  • 1
    "some times, most of the time, 98% of the time"? Commented Jan 4, 2013 at 19:03
  • well, where you are echoing $reply variable? It is storing the returned data! Commented Jan 4, 2013 at 19:08
  • @MarcB thats funny! but try to figure his problem out :D Commented Jan 4, 2013 at 19:09
  • I am echoing the $reply, which does say "it works" on one server. The other server still remains blank. I've even disabled both firewalls and it's still not working. Sorry I didn't add that last bit of code, but it is there. Commented Jan 4, 2013 at 22:36

1 Answer 1

1

Turns out what I believed to be opening the firewall to allow incoming and outgoing connections was only allowing incoming, not outgoing. I also resolved a DNS error under resolv.conf and things are now working correctly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.