I'm new here to write, but read lots of answers in the past few years, so first of all: thanks for the lot of help you gave me so far! So, this is what makes me crazy today, and couldn't find the answer anywhere:
I have a web service (an Openfire plugin) and a LAMP-based backoffice (on a separate box), which manages the Openfire remotely. After migrating the Openfire to a new (3rd) box, the backoffice code stopped working. Here is a snippet:
<?php
header("Content-Type: text/plain");
$url = "http://gbbackup.dyndns.org:9090/plugins/goldsteinAdmin/goldsteinadmin"; echo $url."\n";
$ch = curl_init($url); echo "handle: ".$ch."\n";
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, fopen('php://stdout', 'w'));
$result = curl_exec($ch); echo "Result: ".$result."\n";
if ($result === false) echo 'cURL error '.curl_errno($ch).': '.curl_error($ch)."\n";
print_r(curl_getinfo($ch));
curl_close($ch);
?>
Curl's verbose output is:
* About to connect() to gbbackup.dyndns.org port 9090 (#0)
* Trying 81.183.210.206... * Connection refused
* couldn't connect to host
* Closing connection #0
Now the strange thing is if I try via command line, it works perfectly:
user@login01:~/public_html/gb$ curl -v "http://gbbackup.dyndns.org:9090/plugins/goldsteinAdmin/goldsteinadmin"
* About to connect() to gbbackup.dyndns.org port 9090 (#0)
* Trying 81.183.210.206... connected
* Connected to gbbackup.dyndns.org (81.183.210.206) port 9090 (#0)
> GET /plugins/goldsteinAdmin/goldsteinadmin HTTP/1.1
> User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6
> Host: gbbackup.dyndns.org:9090
> Accept: */*
>
< HTTP/1.1 200 OK
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Set-Cookie: JSESSIONID=12e1urcewodgr;Path=/
< Content-Type: application/json;charset=ISO-8859-1
< Transfer-Encoding: chunked
<
{"type":"error","msg":"RequestNotAuthorised"}
* Connection #0 to host gbbackup.dyndns.org left intact
* Closing connection #0
What could be the difference between the PHP and the command line curl? I have removed all the fancy extras just to test the connection itself, but some difference must be remained.
I made some more tests, here are the results:
- PHP curl to other websites (e.g. google.com): works
- inserted the link into Chrome on my own machine: works
- tested command line curl via php system(): does not work
- I also wanted to tcpdump the differences, but on the other box, where I have root privileges, both PHP and command line version works
It seems just these two boxes do not like eachother :-)
Thanks in advance for your help!