curl and php - connection refused

rgelen

Registered
Sep 4, 2019
2
0
1
Forres, NE Scotland
cPanel Access Level
Website Owner
Hello...

We're working with our developer to create a music royalty tracking database for our internet radio station.

We use curl from PHP to pull in "now playing" metadata from our streaming server's "streaminfo" URL.

During development, our developer used his own server to build the system and all was well.

Now that he has moved it over to a cPanel-based server we have commissioned from our hosting company specifically for the purpose, this call no longer works, and neither we (nor our hosting provider) can work out why. We would appreciate some suggestions.

Our new cPanel-based database server has the hostname admin.ourstation.org ; our streaming server we can call streams.ourstation.org (NOTE: domain anonymized).

We're trying to pull in the data from https://streams.ourstation.org:2199/rpc/ourstation/streaminfo.get. It constantly returns "Failed to connect to streams.ourstation.org port 2199: Connection refused" - but only when accessed from our admin.ourstation.org host. All other machines we can test from return the data flawlessly.

Our developer has done the following:

1. Run a test call (similar to that shown below - don't try it as the domains aren't real) from admin.ourstation.org to several other hosts and all return the desired data
2. Run the test call below from several other hosts to return data from streams.ourstation.org and all return the desired data
3. Our developer and I can both return data from streams.ourstation.org with manual curl calls from our desktop machines' command line.
4. Our developer has been able to recover data from streams.ourstation.org from the prototype system on his own server from the beginning (and still can).

So, from our cPanel server we can return data using curl from a wide variety of sources all successfully.
Similarly, we can pull data off our streaming server from virtually any host but NOT ours!
ONLY the test from admin.ourstation.org to streams.ourstation.org fails.

Are there challenges involving running curl between two hosts in the same domain? Anyone suggest a cause of this strangely specific issue?

We would be most grateful for any observations. Thanks in advance!

--Richard E

TEST CODE

<?php
header("Content-type: application/json; charset=utf-8");

$url = "https://streams.ourstation.org:2199/rpc/ourstation/streaminfo.get";


$mysession = curl_init();
curl_setopt($mysession, CURLOPT_URL, $url);
curl_setopt($mysession, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($mysession, CURLOPT_CONNECTTIMEOUT , 10);
curl_setopt($mysession, CURLOPT_FAILONERROR, true);
$json = json_decode(curl_exec($mysession), true);


if (curl_errno($mysession)) {
echo "error: " . curl_error($mysession);
}else{
echo json_encode($json,JSON_PRETTY_PRINT);
}

?>



 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
Connection Refused sounds like a firewall block. Can you confirm that the firewall on the admin server has the necessary ports open? I'd also whitelist the IP's of the admin server on the streams server and vice versa.
 

rgelen

Registered
Sep 4, 2019
2
0
1
Forres, NE Scotland
cPanel Access Level
Website Owner
Hello and thanks for the reply.

We don't have direct access to any firewall on the cPanel "admin" machine as far as we are aware, though I have asked our provider to check. We've also asked them to confirm that port 2199 is open too. We don't have access to iptables so we can't whitelist the streams server on the admin machine but I'll ask about that too. The streams server has the admin machine's IP whitelisted - which had no effect.

We do not expect the "streams" machine to require any port opening or whitelisting as there is a web server on there (obviously) that we use for stream configuration and accessing the data which works successfully with a web browser pointed at that port.

Certainly at this point we certainly tend towards the opinion that some kind of firewall or similar measure is in the way. The "streams" server is a dedicated server and we can do more or less anything we like (except it is working beautifully and I don't want to break it), though I have asked the server provider to confirm that the "admin" server isn't on some blacklist or other with them. With the cPanel "admin" machine we can only access it via the methods provided by cPanel and do not have a shell account. We're running cPanel 78.0.37. We imagine that any firewall setup would be separate and we've asked our provider about that too.

Our developer has just let me know that he has been able to access another cPanel server and has tried using curl to connect to "streams" and notes that this fails in the same way as with the "admin" server. So I am wondering if there is a standard or commonly-configured cPanel feature or parameter that might be causing this?

As always, many thanks for comments and suggestions.
--Richard E
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,301
363
Houston
We don't have direct access to any firewall on the cPanel "admin" machine as far as we are aware, though I have asked our provider to check. We've also asked them to confirm that port 2199 is open too. We don't have access to iptables so we can't whitelist the streams server on the admin machine but I'll ask about that too. The streams server has the admin machine's IP whitelisted - which had no effect.
Ultimately I'm leaning toward the admin server here having the issue here not the stream server, especially since that server doesn't have issues performing this action in conjunction with other servers.

With the cPanel "admin" machine we can only access it via the methods provided by cPanel and do not have a shell account. We're running cPanel 78.0.37. We imagine that any firewall setup would be separate and we've asked our provider about that too.
In this case, if you only have access to the cPanel account you wouldn't be able to manage the firewall at all and would need to work with your provider on this.

Our developer has just let me know that he has been able to access another cPanel server and has tried using curl to connect to "streams" and notes that this fails in the same way as with the "admin" server. So I am wondering if there is a standard or commonly-configured cPanel feature or parameter that might be causing this?
Not that I'm aware of, it may be that they both run the same firewall software that has the same ports open/closed but this isn't really enough information to make that determination.