Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cURL doesn't work on the Google App Engine environment #13

Closed
adamyeats-zz opened this issue Nov 18, 2013 · 21 comments
Closed

cURL doesn't work on the Google App Engine environment #13

adamyeats-zz opened this issue Nov 18, 2013 · 21 comments

Comments

@adamyeats-zz
Copy link
Contributor

Via support: "It seems that your php library uses cURL which is not supported on GAE PHP"

On further inspection, it seems this is correct. If we want to support this platform, urlfetch might be a better solution.

@ajessup
Copy link

ajessup commented Nov 19, 2013

Google App Engine supports http streams (which uses urlfetch() under the hood). So commands like file_get_contents() and fopen() will work.

@ewwink
Copy link

ewwink commented Jan 7, 2014

urlfetch in php (file_get_contents) https://developers.google.com/appengine/docs/php/urlfetch/

@leggetter
Copy link
Contributor

See: #14

@dvhirst
Copy link

dvhirst commented Nov 6, 2014

It seemed as of late last year (2013) that GAE developers were headed toward providing cURL functions within GAE (ref: https://code.google.com/p/googleappengine/issues/detail?id=9343). Now it is nearly a year later, but there is no update on the status of this issue. Closing this issue by providing cURL functionality in GAE would make life much easier for many folks. Is there a way to increase the attention to this issue?

@ajessup
Copy link

ajessup commented Nov 7, 2014

(disclaimer, I work on the GAE PHP team)

Starring the issue is a great way to signal it's importance. cURL support is still very much on the roadmap, even if we've been a little quiet this year.

That said, any reason this implementation focuses on cURL rather than streams?

@dvhirst
Copy link

dvhirst commented Nov 7, 2014

It seems many php projects use the curl library; the ability to use existing projects without tearing into their internal functionality is key to my ability to support my organization. I have the ability to understand what's going on, but changing project internals feels a bit risky to me, and would require investment of more time and effort than I can give as a volunteer resource.

@mtdowling
Copy link

@ajessup cURL is one of the most popular PHP extensions and is used in hundreds of projects on Packagist (for example, cURL is the default HTTP handler for Guzzle). Developers often choose cURL over PHP's stream wrapper because cURL offers far more flexibility and performance (e.g., persistent connections).

@Raxvis
Copy link

Raxvis commented Jan 15, 2015

@ajessup while I can see streams being very useful, I can't help but fully agree with @mtdowling on this. In so many of my projects, I find using cURL much more enjoyable, flexible and powerful not to mention the huge list of libraries that already rely on cURL

@mtdowling
Copy link

It should also be noted that the Google App Engine stream wrapper implementation doesn't appear to support using a custom CA bundle (or any ssl context option other than "verify_peer"): https://cloud.google.com/appengine/docs/php/urlfetch/

There are a few considerations to keep in mind when using these wrappers in your Google App Engine application:

  • When connecting to web sites using HTTPS, the default behavior is to validate the certificate of the host and reject requests where the vertificate does not match. This is the opposite to the default behavior of PHP, and to change this behavior you can set the value of verify_peer to false in the ssl section of the context parameters.
  • All other values of ssl contexts options are ignored.

This makes an even stronger case for adding cURL support. But even if support cURL is added, the other ssl context options should be supported.

@dvhirst
Copy link

dvhirst commented Jan 15, 2015

Folks, this issue has caused me to stop my work to implement CiviCRM /
WordPress on GAE. I've spent the past couple of days (not weeks and
months) implementing the same (actually newer and better) configuration on
Amazon Web Services, and it has gone very smoothly so far. I'd really
rather be on Google, but it just hasn't worked. FWIW, YMMV.

Regards,

Don Hirst

On Thu, Jan 15, 2015 at 2:33 PM, Michael Dowling notifications@github.com
wrote:

It should also be noted that the Google App Engine stream wrapper
implementation doesn't appear to support using a custom CA bundle (or any
ssl context option other than "verify_peer"):
https://cloud.google.com/appengine/docs/php/urlfetch/

There are a few considerations to keep in mind when using these wrappers
in your Google App Engine application:

  • When connecting to web sites using HTTPS, the default behavior is to
    validate the certificate of the host and reject requests where the
    vertificate does not match. This is the opposite to the default behavior of
    PHP, and to change this behavior you can set the value of verify_peer to
    false in the ssl section of the context parameters.

  • All other values of ssl contexts options are ignored.

    This makes an even stronger case for adding cURL support. But even if
    support cURL is added, the other ssl context options should be supported.


Reply to this email directly or view it on GitHub
#13 (comment)
.

@Neira1991
Copy link

I am developing a mobile app on Google app engine, and it has been difficult to implement gcm, the community recommends "urlfetch" but will that urlfetch can replace curl to gcm on Google App engine?

@dvhirst
Copy link

dvhirst commented Jul 3, 2015

Another six months have passed with no action on this topic. Is Google going to address cURL or not?

@Raxvis
Copy link

Raxvis commented Jul 3, 2015

cURL is now allowed on GAE. In your app.yaml file you need this:

runtime: php55

Then you will need to create a php.ini file in your root directory with the line

extension = "curl.so"

See here: https://cloud.google.com/appengine/docs/php/#dynamically_loadable_extensions

You will need to enable billing

@dvhirst
Copy link

dvhirst commented Jul 3, 2015

Thanks for this information. I'll follow up on it.

@Raxvis
Copy link

Raxvis commented Jul 3, 2015

Yup, no worries. Just a heads up. After enabling the billing, it will take a bit for it to be activated. I usually wait an hour or so before testing it.

@scripthead
Copy link

This still doesn't seem to work. I have billing enabled on the project and the following in app.yaml

runtime: php55

and this in php.ini

extension = "curl.so"

and the script

$ch = curl_init('http://google.com/');
$response = curl_exec($ch);
echo '<pre>' . print_r(curl_getinfo($ch),1);
echo '<pre>' . print_r(curl_error($ch),1);
echo '<pre>' . print_r($response,1);
die;

but it produces the following output:

Array
(
    [url] => http://google.com/
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0
    [namelookup_time] => 0.047984
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 
    [certinfo] => Array
        (
        )

    [primary_port] => 0
    [local_ip] => 
    [local_port] => 0
)

notice the content type and http code are empty. On a local environment the same code produces

Array
(
    [url] => http://google.com/
    [content_type] => text/html; charset=UTF-8
    [http_code] => 302
    [header_size] => 234
    [request_size] => 49
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.157038
    [namelookup_time] => 0.068574
    [connect_time] => 0.112838
    [pretransfer_time] => 0.112901
    [size_upload] => 0
    [size_download] => 262
    [speed_download] => 1668
    [speed_upload] => 0
    [download_content_length] => 262
    [upload_content_length] => 0
    [starttransfer_time] => 0.156984
    [redirect_time] => 0
    [redirect_url] => http://www.google.com.ua/?gfe_rd=cr&ei=CnMNVuyVAqWG8Qe0pJLICQ
    [primary_ip] => 173.194.112.14
    [certinfo] => Array
        (
        )

    [primary_port] => 80
    [local_ip] => 192.168.0.3
    [local_port] => 53909
)

@Raxvis
Copy link

Raxvis commented Oct 1, 2015

Did you set a billing limit?

@scripthead
Copy link

I have billing limited to $50/day and haven't used over $2 in the last week.

@Raxvis
Copy link

Raxvis commented Oct 1, 2015

http://terrenceryan.com/blog/index.php/php-on-app-engine-does-curl/

cURL is limited by the restrictions of App Engine’s sockets but include:

  • Limited from targeting Google domains
  • May be reclaimed after 2 minutes of inactivity

Try calling a different domain instead of Google

@scripthead
Copy link

That did it! Thank you.

@Raxvis
Copy link

Raxvis commented Oct 1, 2015

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants