mollie / mollie-api-php

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

Payment Create API call keeps timing out #492

Closed duncanmcclean closed 4 years ago

duncanmcclean commented 4 years ago

Specifications

Describe the issue

I'm trying to create an integration for Mollie for the e-commerce software that I build. However, whenever I try to make a request to the payment create endpoint using this API or through the Laravel version (which uses this SDK) I always seem to get a timeout error.

cURL error 28: Resolving timed out after 10057 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

This is the code I'm using to make the request, it's pretty much the same as in the readme of this package.

$payment = $this->mollie->payments->create([
            'amount' => [
                'currency' => 'GBP',
                'value' => '25.00',
            ],
            'description' => 'Order: #1234',
            'redirectUrl' => 'http://simple-v2.test/!/simple-commerce/gateways/mollie/redirect',
            'webhookUrl'  => 'http://simple-v2.test/!/simple-commerce/gateways/mollie/webhook',
]);

I'm thinking this could be an issue with Mollie's systems, maybe? Could be it be an issue that the API key it's using is for a new account that's not been activated yet or could it be an issue to do with the two urls not being reachable (they are localhost URLs from Laravel Valet).

...

sandervanhooft commented 4 years ago

This behavior is not caused by unreachable webhooks or inactivated accounts. Afak there have been no availability issues over the last week. So we'll have to investigate. Can you contact support and let them know where you're making the calls from, and your account #id? The latter can be found in the top left corner in the Mollie dashbord.

One temporary workaround could be to inject your own Guzzle client into the MollieApiClient, with a higher timeout limit. (In Mollie it's set to 10 seconds currently).

Hope that helps

duncanmcclean commented 4 years ago

Thanks @sandervanhooft. I'll do that now and I'll update this issue if when I figure out the issue.

Softens commented 4 years ago

We have this exact same issue on our webshops. I've submitted the contact form in the Mollie dashboard.

willemstuursma commented 4 years ago

Hi @damcclean and @Softens. Do you have this problem on 100% of the Create Payment API calls?

Could you enlighten us where your servers are located (in the world) and what DNS resolver you are using?

duncanmcclean commented 4 years ago

Hi @damcclean and @Softens. Do you have this problem on 100% of the Create Payment API calls?

Could you enlighten us where your servers are located (in the world) and what DNS resolver you are using?

Yeah, I've tried multiple times and every time I've got a timeout.

I'm just using my laptop's dev environment. I'm in the United Kingdom and my DNS is pointing to OpenDNS.

vedran-mollie commented 4 years ago

Hi @damcclean and @Softens. Do you have this problem on 100% of the Create Payment API calls? Could you enlighten us where your servers are located (in the world) and what DNS resolver you are using?

Yeah, I've tried multiple times and every time I've got a timeout.

I'm just using my laptop's dev environment. I'm in the United Kingdom and my DNS is pointing to OpenDNS.

Hi @damcclean and @Softens, could you please attempt a manual resolution with e.g.:

dig +trace api.mollie.com

and paste the resulting output here (so we can try to pinpoint where the failure to resolve might come from)

duncanmcclean commented 4 years ago

@vedran-mollie Sure... here's my output.

; <<>> DiG 9.10.6 <<>> +trace api.mollie.com
;; global options: +cmd
.           518400  IN  NS  a.root-servers.net.
.           518400  IN  NS  b.root-servers.net.
.           518400  IN  NS  c.root-servers.net.
.           518400  IN  NS  d.root-servers.net.
.           518400  IN  NS  e.root-servers.net.
.           518400  IN  NS  f.root-servers.net.
.           518400  IN  NS  g.root-servers.net.
.           518400  IN  NS  h.root-servers.net.
.           518400  IN  NS  i.root-servers.net.
.           518400  IN  NS  j.root-servers.net.
.           518400  IN  NS  k.root-servers.net.
.           518400  IN  NS  l.root-servers.net.
.           518400  IN  NS  m.root-servers.net.
.           518400  IN  RRSIG   NS 8 0 518400 20200929050000 20200916040000 46594 . srE+58HLurdJCozEyK/I/6ewSUlbtFoKjAqPgBBWHha0mjwEQ/bowuU3 OFIBF9SXys+sXt88PfVM3WNtkgzjrxh+mHVZGAgRroPlLrqu8/nZB1WN Tqbf05YxBimbozP1yVWFkHh4kS7gkl2rjVl+klI4VxFMxoX3r8DtYIO9 XYq8Z7lEuGi1OzUu36Y2zM/1hdIU1Qpeq6oMY+IISpu3roM2hC8mbRgo bjbfPrkPNR29BvjEWgeUtUwtyzXZ2mMS3jkWhNfudqbRkJxdBjJd+MJm LoVkfcdZWArf3HlEVy4SytQxZmwEQLcU5+c6uftQJOHrKN1sXIid1mxs Gdfajw==
;; Received 525 bytes from 208.67.220.220#53(208.67.220.220) in 137 ms

com.            172800  IN  NS  a.gtld-servers.net.
com.            172800  IN  NS  b.gtld-servers.net.
com.            172800  IN  NS  c.gtld-servers.net.
com.            172800  IN  NS  d.gtld-servers.net.
com.            172800  IN  NS  e.gtld-servers.net.
com.            172800  IN  NS  f.gtld-servers.net.
com.            172800  IN  NS  g.gtld-servers.net.
com.            172800  IN  NS  h.gtld-servers.net.
com.            172800  IN  NS  i.gtld-servers.net.
com.            172800  IN  NS  j.gtld-servers.net.
com.            172800  IN  NS  k.gtld-servers.net.
com.            172800  IN  NS  l.gtld-servers.net.
com.            172800  IN  NS  m.gtld-servers.net.
com.            86400   IN  DS  30909 8 2 E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CF C41A5766
com.            86400   IN  RRSIG   DS 8 1 86400 20200929050000 20200916040000 46594 . wEr6idWRwTDagb7K5sFOxEHdjfQH+iXWoROlJS3RCFYjP8BV19uxbSd8 vb4piF+kj9d8bYyLSDCcnKUjyOTX15ngaQjKEZlPfkfUQQKx74C/N1WF VWdrzXHXRJ8AruuRelLclRkN2EgaKygPwHXrSi3y1660MxCOrWdB+Dk3 w/LMLZi8pT2/WlN9c2y5Ws8xlUilj9VPuNCN1m7EIvWB2uNbtDgN7VlD GT1HVoiRvgNiSovWd7Gmsh84qAcM5CMlT6q7G4e2qzUresJ248NoHsvA KFECkCoS37szLcTVNmgNuFxASdgypF+/4yJNmqYF6FCcV6kg7mG8PnMu HKsVBA==
;; Received 1174 bytes from 199.7.83.42#53(l.root-servers.net) in 47 ms

mollie.com.     172800  IN  NS  ns1.transip.nl.
mollie.com.     172800  IN  NS  ns0.transip.net.
mollie.com.     172800  IN  NS  ns2.transip.eu.
mollie.com.     86400   IN  DS  19800 7 1 542CD6F50CC44F2DD327DC2D9578EC15EBF0B9CA
mollie.com.     86400   IN  RRSIG   DS 8 2 86400 20200922041802 20200915030802 24966 com. yuia8UglQXDOYPAlqkaekrLjLGB07B3jtU53EO5oGk6TRBBagICETUS/ Q1Va0I+IqKoa/cBRdz7dazHEjVnla4kRWfpuznOG2TqdZUuFfHeAQv0e Henug1CXChzVtDe4Sr6I4PQa9kqP7yoqKOjd3dXzRSu58r/YdG+ahnXk Z0BLT7loRjp1Ql5Vytuvn/+I5EuXtpX3YWxlAMGUFYVPoA==
;; Received 359 bytes from 192.42.93.30#53(g.gtld-servers.net) in 111 ms

api.mollie.com.     3600    IN  A   87.233.95.3
api.mollie.com.     3600    IN  RRSIG   A 7 3 3600 20210104121748 20200904121748 9137 mollie.com. DHdCdEZGaj4sXG9NtX2NN5L+t06eCE4+BCEGgw+hXZ1A7kGKLHsczbGY 6sCBk8enBZlh3bmh137MuVrQtJoRw6Pv/ozJRIuHR3FbZx5xJUGBfJZA jHk59kUPOObWqi+wlkunVN7VvgmiYFPjYf4Ya+XNjUEmR9GVlTleInSe zeU=
;; Received 257 bytes from 195.8.195.195#53(ns1.transip.nl) in 27 ms
duncanmcclean commented 4 years ago

Alright, I've went ahead and passed in my own Guzzle client to the MollieApiClient constructor, basically exactly the same but with a timeout of 60 seconds, instead of 10 seconds which is the default. Like suggested by @sandervanhooft.

And now I'm able to make requests to Mollie and get a response back! 🎉

But I guess the question still remains... why does it take over 10 seconds to reach Mollie's servers?

Softens commented 4 years ago

Here is my output:

# dig +trace api.mollie.com

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7_8.6 <<>> +trace api.mollie.com
;; global options: +cmd
;; Received 17 bytes from 2a01:7c8:7000:195:0:8:195:8#53(2a01:7c8:7000:195:0:8:195:8) in 0 ms

Tried the following commands as well:

curl google.com -I
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Wed, 16 Sep 2020 18:32:21 GMT
Expires: Fri, 16 Oct 2020 18:32:21 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
curl api.mollie.com -I
(no response)

I'm in The Netherlands (AMS0) using Cloudflare.

Tried to set the timeout to 60 seconds, but the page keeps loading for 60 seconds now and it still not redirecting to Mollie.

Softens commented 4 years ago

I've changed the ipv6 nameservers to ipv4 nameservers. New results:

dig @127.0.0.1 +trace google.com

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7_8.6 <<>> @127.0.0.1 +trace google.com
; (1 server found)
;; global options: +cmd
.                       3600000 IN      NS      I.ROOT-SERVERS.NET.
.                       3600000 IN      NS      M.ROOT-SERVERS.NET.
.                       3600000 IN      NS      L.ROOT-SERVERS.NET.
.                       3600000 IN      NS      K.ROOT-SERVERS.NET.
.                       3600000 IN      NS      F.ROOT-SERVERS.NET.
.                       3600000 IN      NS      C.ROOT-SERVERS.NET.
.                       3600000 IN      NS      A.ROOT-SERVERS.NET.
.                       3600000 IN      NS      J.ROOT-SERVERS.NET.
.                       3600000 IN      NS      D.ROOT-SERVERS.NET.
.                       3600000 IN      NS      E.ROOT-SERVERS.NET.
.                       3600000 IN      NS      G.ROOT-SERVERS.NET.
.                       3600000 IN      NS      H.ROOT-SERVERS.NET.
.                       3600000 IN      NS      B.ROOT-SERVERS.NET.
 dig +trace api.mollie.com

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7_8.6 <<>> +trace api.mollie.com
;; global options: +cmd
;; connection timed out; no servers could be reached
vedran-mollie commented 4 years ago

@Softens why do you specify the local resolver for google.com but not one for api.mollie.com? What happens if you try something completely different for the api.mollie.com call (@8.8.8.8 for example)?

Softens commented 4 years ago

@vedran-mollie Looks like the IPv6-address was blocked. I've changed the address of the outgoing requests to our IPv4 address (in the NetworkManager) and that works. As requests to other websites, except for the Mollie website, are working, I conclude that the IPv6 address has been blocked by Mollie.

rares-mollie commented 4 years ago

@Softens, sorry for the radio silence, we've been quite busy debugging this issue over the past few days. We will have a workaround for you to test on Tuesday.

willemstuursma commented 4 years ago

Hi @Softens and @damcclean.

We have set up a temporary alternative domain for accessing our api: api.mollie.ch. This is set up with a different DNS provider. We think our current DNS provider is the issue.

We would appreciate if you can test if switching to this domain will resolve your issues and report back here.

Note that we will migrate our existing DNS infrastructure as well in the coming months and that you should switch back to api.mollie.com between December 1st and January 1st. After Jan 1st 2021 we will remove the the api.mollie.ch domain.

sandervanhooft commented 4 years ago

Note: you can change the endpoint on the client like this:

MollieApiClient::API_ENDPOINT = ...

willemstuursma commented 4 years ago

@sandervanhooft Instead of changing library code, it would better to call setApiEndpoint().

Please be aware that this new hostname is temporary and will be removed after January 1st, 2021.

duncanmcclean commented 4 years ago

I've just removed my custom Guzzle client and passed in the new endpoint with setApiEndpoint() but I'm still getting the same timeout error.

cURL error 28: Resolving timed out after 10072 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

If I pass in my custom client that changes the timeout from the default 10 seconds to 30 seconds, it works but that's really just a workaround.

This is how I'm setting up the Mollie client:

$this->mollie = new MollieApiClient();
$this->mollie->setApiKey('...');
$this->mollie->setApiEndpoint('https://api.mollie.ch');

I appreciate the time and effort you're spending to fix this issue.

duncanmcclean commented 4 years ago

In case you're interested, I've just re-run that dig command on this new API domain, here's my result:

➜  ~ dig +trace api.mollie.ch

; <<>> DiG 9.10.6 <<>> +trace api.mollie.ch
;; global options: +cmd
.           518400  IN  NS  a.root-servers.net.
.           518400  IN  NS  b.root-servers.net.
.           518400  IN  NS  c.root-servers.net.
.           518400  IN  NS  d.root-servers.net.
.           518400  IN  NS  e.root-servers.net.
.           518400  IN  NS  f.root-servers.net.
.           518400  IN  NS  g.root-servers.net.
.           518400  IN  NS  h.root-servers.net.
.           518400  IN  NS  i.root-servers.net.
.           518400  IN  NS  j.root-servers.net.
.           518400  IN  NS  k.root-servers.net.
.           518400  IN  NS  l.root-servers.net.
.           518400  IN  NS  m.root-servers.net.
.           518400  IN  RRSIG   NS 8 0 518400 20201012050000 20200929040000 46594 . EUNUgwVVvcgdX6JRCPfmhFPuIJW8DZf7ww1hQAgek0GPDT7kc75fER5Z NpASxPhrTQKentVt/C5ptwa0Z58i8O7XyN6Pu5ZIZrOpG5zV6y0FqLnI B7L01ugkmTdZIxfqTxbyiTh8hTWspskbAYQrnrSPiotX0+POYlw7ZIwX R6V7Y2mF48wFclaejrPRQy/ee03QKYyT9nYPahe7i0qnbmvk1JAfDiCw dR6Aa2hm/RSuW+7nJRqCbeDZZ4mU1lAZDiyUQ1ezAl/HcCCcpBud8iae DBYFXDX86EP0hXQexpzN5MLUQZuTCIq5Ihz9Vqk0orXmeaZ/k56t/2td /ak8sw==
;; Received 525 bytes from 208.67.220.220#53(208.67.220.220) in 28 ms

ch.         172800  IN  NS  a.nic.ch.
ch.         172800  IN  NS  b.nic.ch.
ch.         172800  IN  NS  c.nic.ch.
ch.         172800  IN  NS  e.nic.ch.
ch.         172800  IN  NS  f.nic.ch.
ch.         172800  IN  NS  g.nic.ch.
ch.         172800  IN  NS  h.nic.ch.
ch.         86400   IN  DS  55966 13 2 CEB479416E4EFD770800434BE1245E1B10D4CF018255C11D8544C448 FA032B32
ch.         86400   IN  RRSIG   DS 8 1 86400 20201012050000 20200929040000 46594 . LsbEJ2D/F8pAC8SM3MinYsnzLu/xtwdS9PvB8YCeHsHqBzdypUzaEd4b SeLxC4TLmQWqsaCSN3ohPvNXSNflmphZ3kq0n2m4gtWAtqal8sqJVe03 EYj+yidsx7zFTOHNzQJt8ZtHz7xK3pd/2fe3NAIrNVYhL4W8mMOZlf7E AydDGhO74wv+S1Ydz6b9Xl4nqE/C3cXTFvmhwYBYthkArVQgq2sj4zIW 7jHMOSEPV5n9pkfZdZa5JKqOT8QZXaChppPnNuhC0XoNj3q2b/lWhVeA 6sBDBEAEx1jMgossQkmulyWlv2T8nzcIunF8kekiOBq+sfI72hMWWfew tcGqPA==
;; Received 801 bytes from 192.58.128.30#53(j.root-servers.net) in 25 ms

mollie.ch.      3600    IN  NS  ns-cloud-b1.googledomains.com.
mollie.ch.      3600    IN  NS  ns-cloud-b2.googledomains.com.
mollie.ch.      3600    IN  NS  ns-cloud-b3.googledomains.com.
mollie.ch.      3600    IN  NS  ns-cloud-b4.googledomains.com.
mollie.ch.      3600    IN  DS  48626 8 2 951C543D9C349D6CAA4E9F2E608C496C1DB3F3EAD66CF9571B751A12 201AB005
mollie.ch.      3600    IN  RRSIG   DS 13 2 3600 20201024123831 20200924120241 13190 ch. aQFAJS2RE3QAp/Ks0DDxEwy15vnz/L7QKS9qTtT5FE6staNfx5zqoueu qRe7qjo9yA7ZbisvwS8CZx7kavJDRg==
;; Received 360 bytes from 194.0.1.40#53(g.nic.ch) in 21 ms

api.mollie.ch.      60  IN  A   87.233.95.3
api.mollie.ch.      60  IN  RRSIG   A 8 3 60 20201018095858 20200926095858 13689 mollie.ch. DYGyF9YEUjKCp4OSPcH3rVkEnNRyogNo3g+eLxBfdJENgZP+848cDL9w oRevar2DjhyUni07StCFDR7oKUZxsm6WIho5EvLnaATlKd/Tlrz8nk3a UqiyQLhsndWTWh3HfCqXYNUdMo/uaiUIOtsrw3bKI6Hx5OOHrfdGlXlt ul8=
;; Received 227 bytes from 216.239.36.107#53(ns-cloud-b3.googledomains.com) in 63 ms
willemstuursma commented 4 years ago

Hi @damcclean @Softens.

We've migrated api.mollie.com to our new DNS infra provider.

You should remove any references to the .ch domain.

willemstuursma commented 4 years ago

If you have any remaining problems with resolving our DNS, please re-open this issue.

duncanmcclean commented 4 years ago

Thanks @willemstuursma for your response!

I actually managed to resolve the issue I was having locally with resolving the Mollie API last week while trying to fix another timeout API issue.

All I did was change my local DNS servers away from OpenDNS (who I used previously) to Cloudflare's DNS server (1.1.1.1) and the response time dropped and I don't seem to have any issues again, even if I switch back to OpenDNS🤔 Something must have been cached.

vedran-mollie commented 3 years ago

For reference: the api.mollie.ch temporary domain name is no longer functional