mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
552 stars 191 forks source link

Increase cURL timeout #470

Closed xqsit94 closed 4 years ago

xqsit94 commented 4 years ago

Specifications

Describe the issue

I get this following error due to timeout of 10 seconds

2020-07-08_19-45

cURL error 28: Resolving timed out after 10000 milliseconds

2020-07-08_19-42

Increase the curl timeout to at-least 20 - 30 seconds which is added in this PR #291

sandervanhooft commented 4 years ago

The timeout is currently 10 seconds, which should be long enough. What are you trying to do?

If you really need a longer timeout, you can inject a customized Guzzle client into the MollieApiClient.

xqsit94 commented 4 years ago

Every single api takes more than 10s to respond you can see it in attached screenshot. How could you say it is long enough? Server response time is not same across the world.

sandervanhooft commented 4 years ago

I understand.

As a default setting, the 10s is fine. Further increasing the timeout may cause issues in other integrations. Also note that Mollie is only available to European merchants, and for legal reasons (GDPR) their servers generally need to be in Europe.

Again, if you need a longer timeout, you can inject a customized Guzzle client into the MollieApiClient constructor:

$timeout = 20; // or 30, whatever you need

$guzzleClient = new Client([
                \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getBundledCaBundlePath(),
                \GuzzleHttp\RequestOptions::TIMEOUT => $timeout,
            ]);

$mollie = new MollieApiClient($guzzleClient);
$mollie->setApiKey(/*...*/);

// Ready to go
$mollie->payments->page();
willemstuursma commented 4 years ago

Hi @xqsit94. Can you let me know where in the world you are operating from?

xqsit94 commented 4 years ago

@sandervanhooft Thanks for your response. I injected that already, I'm working for an European client the response time of server is 15+ seconds here and I'm operating from India @willemstuursma .

holtkamp commented 4 years ago

Note that this reminds me of https://github.com/mollie/mollie-api-php/issues/414

willemstuursma commented 4 years ago

Thanks @xqsit94. That's an insane slowness.

Can you post a traceroute here:

traceroute api.mollie.com

Maybe that will clear up where this slowness is coming from.