RobrechtVM
RobrechtVM

Reputation: 936

PHP curl request results in white page when the url contains dots or colons

This only happens on my webserver, not on the local system. I have a curl request like this

ini_set('display_errors', 1);
error_reporting(E_ALL);

$url = 'http://***.***.***.***:8080/api_v1/oauth/token';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$response = curl_exec($ch);

This makes the page loading for a while and just returns a white screen. It is really impossible to show errors, output or just anything else.

Whenever I change the url to another url (existing or not existing) i get proper errors or output if the url makes sense, as long as the url does not contain any dots or colons...

Is there any restriction for the usage or a curlopt I am missing? I have no control over the target url, I need to consume the api in the ip:port structure.

UPDATE

  1. The problem is not related to the target URL or data coming in: the same problem occurs when I enter a url that makes no sense at all as long as it doesn't contain . or :
  2. I guess it is a setting on the webserver since all my tests work fine on localhost (MAMP)
  3. Unfortunately I have no access to any logs or files except the ones I upload myself (one.com webhosting)

UPDATE 2

Turns out my hoster is blocking all outgoing traffic to implicit IP's and ports other than 80 and 443. Cancelled my subscription and taking a decent provider now. Thanks for the help

Upvotes: 1

Views: 412

Answers (2)

RobrechtVM
RobrechtVM

Reputation: 936

Turns out my hoster is blocking all outgoing traffic to implicit IP's and ports other than 80 and 443. Cancelled my subscription and taking a decent provider now. Thanks for the help

Upvotes: 0

Zeth
Zeth

Reputation: 2598

As @Quasimodo suggests, then I'd take a look in the log-file, if I were you. If you're on a Ubuntu-server using Apache, then look at /var/log/apache2/error.log. A neat trick is to open a terminal and write:

tail -f /var/log/apache2/error.log

This will open a running stream to the terminal. Then you can make your curl-request crash (in your browser) and then go back to the terminal and see what new and juicy errors you have received.

It's most likely some configuration-file on your server. So it would be helpful, if you write a couple of specs from that server, such as: - Which web server you're using (Apache, Nginx, other) - PHP version ... You can find all of these information easily using phpinfo.

My best guess is that you need to enable PHP_Curl for your server configuration, - but it is a buck-wild cowboy shot from the hip.

Addition 1

I can see that you've just editted the question (that it thinks for a while and then gives a blank screen). I'd say, that your curl-request might be trying to load a big amount of data, and that your PHP-configuration has a cap at 128mb (or something).

I'd check the PHPinfo for these two values:

max_input_vars
memory_limit

To see if either of them are suspiciously low.

Upvotes: 1

Related Questions