Network error [errno 2]: easy handle already used in multi handle
stripe-php version: v7.7.1 php version: v7.2.29
I'm experiencing really weird error with the SDK. I got the following error when I create two api calls.
Unexpected error communicating with Stripe. If this problem persists, let us know at
[email protected].
(Network error [errno 2]: easy handle already used in multi handle)
Whenever there are two api calls, it always fails. Not sure if this is something specific for servers.
Following is my code snippet causing this error.
try {
$customer = Customer::retrieve($customerId);
$charges = Charge::all(['customer' => $customer->id]);
} catch (ApiErrorException $e) {
}
Please help me to find out the solution asap.
Hey @kennybuc can you run the Stripe reachability test? https://github.com/stripe/stripe-reachability and share the full output here?
@kennybuc can you confirm which version of curl you're using? we suspect this might be related to the underlying curl setup. Can you also try these settings:
$curl = new \Stripe\HttpClient\CurlClient();
$curl->setEnablePersistentConnections(false);
\Stripe\ApiRequestor::setHttpClient($curl);
Thanks!
@kennybuc can you also share your operating system / environment. Where you're hosting this application? the output of yum info php-curl would also be useful.
Thanks again!
@kennybuc can you confirm which version of curl you're using? we suspect this might be related to the underlying curl setup. Can you also try these settings:
$curl = new \Stripe\HttpClient\CurlClient(); $curl->setEnablePersistentConnections(false); \Stripe\ApiRequestor::setHttpClient($curl);Thanks!
Hello @cjavilla-stripe ,
Rather than using your code lines, I simply updated the value of the following variable in CurlClient class to false and it worked.
protected $enablePersistentConnections = true;
But I think this is not the solution though.
@kennybuc can you also share your operating system / environment. Where you're hosting this application? the output of
yum info php-curlwould also be useful.Thanks again!
When I run yum info php-curl, I got the following error.
Error: No matching Packages to list
Here are some more details about curl version and cent OS version.
>curl --version
curl 7.69.1 (x86_64-redhat-linux-gnu) libcurl/7.69.1 OpenSSL/1.0.1e-fips zlib/1.2.3 c-ares/1.16.0 libssh2/1.8.2
Release-Date: 2020-03-11
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS GSS-API HTTPS-proxy IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB SPNEGO SSL UnixSockets
>cat /etc/centos-release
CentOS release 6.10 (Final)
I agree this isn't a great permanent solution and does add some latency. This is the second report where I have the OS and curl version and they were both CentOS + curl 7.69.1 waiting to hear back from other users I've asked this very same question. It's unclear at what layer of curl this is failing.
@cjavilla-stripe I had a chance to check the code logic for sending curl request in CurlClient. As far as I have checked, it doesn't use curl_multi_init to create curl handle. In a word, it's not clear why easy handle error occurs.
Just heard back from a third user who is encountering this and they are *also using CentOS
@cjavilla-stripe Do you have got any idea about any specific issue for CentOS?
I do not, we're still in the information gathering stage. We know it seems like something related to curl, but there is a wide variety of stripe-php versions that are experiencing this. The only other commonalities of the reports so far is CentOS and curl 7.69.1.
Just for your note, this issue is not just with curl 7.69.1. It was happened with another version of curl, but I can't recall. I have updated curl to the latest version to see if it's working.
good to know. Thanks for that update. Can you share more about where you're hosting? Wondering what other base assumptions we have.
I'm hosting Laravel application and the issue started to happen from yesterday. It was just working fine though.
Hi there, I'm also encountering this error, really bad timing for us unfortunately :((
We're using curl 7.19.7 and CENTOS 6.10
Let me know if I can provide any further info
@Gaffen can you try the temp workaround above while we try to find a more permanent solution?
$curl = new \Stripe\HttpClient\CurlClient();
$curl->setEnablePersistentConnections(false);
\Stripe\ApiRequestor::setHttpClient($curl);
I am also facing this issue from the last couple days, running Laravel on CentOS 6. Any solution for this problem? Its really affecting our subscription site.
Hi everyone. We're still looking into this issue. It's not specific to the Stripe PHP library, but rather appears to be caused by an update to some dependency that was pushed somewhere around Thursday last week.
You can work around the issue by adding the following snippet to your code prior to making any requests to Stripe's API:
$curl = new \Stripe\HttpClient\CurlClient();
$curl->setEnablePersistentConnections(false);
\Stripe\ApiRequestor::setHttpClient($curl);
Note however that this is just a workaround, not a proper fix, and is suboptimal because it disables persistent connections (meaning every request to Stripe's API will create a new connection, causing additional latency).
I've tried reproducing the issue in a CentOS 6 VM, but was unable to do so with any combination of the following:
- PHP: 5.3 (CentOS 6 default) / 7.3 (from https://rpms.remirepo.net/)
- curl: 7.19.1 (CentOS 6 default) / 7.69.1 (from http://www.city-fan.org/)
In order to help us figure out the root cause, it would be great if you could provide us with the following information:
- What exact OS / distribution / version are you using?
- Which hosting provider are you using? (e.g. Linode, DigitalOcean, etc.)
- Are you using cPanel / WHM? If so, which version?
- output of the following commands:
$ php --version
$ php -r "var_dump(curl_version());"
$ yum info php
$ yum info curl
Workaround has indeed worked, however still an issue in v1.0 and 2.0 modes for GiveWP (had to modify core plugin code): https://github.com/impress-org/givewp/issues/4652
Reference so both package maintainers are aware.
php --version output:
PHP 7.3.16 (cli) (built: Apr 14 2020 23:30:31) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.16, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.16, Copyright (c) 1999-2018, by Zend Technologies
php -r "var_dump(curl_version());" output:
array(16) {
["version_number"]=>
int(476417)
["age"]=>
int(5)
["features"]=>
int(11518877)
["ssl_version_number"]=>
int(0)
["version"]=>
string(6) "7.69.1"
["host"]=>
string(23) "x86_64-redhat-linux-gnu"
["ssl_version"]=>
string(14) "OpenSSL/1.1.1f"
["libz_version"]=>
string(5) "1.2.3"
["protocols"]=>
array(22) {
[0]=>
string(4) "dict"
[1]=>
string(4) "file"
[2]=>
string(3) "ftp"
[3]=>
string(4) "ftps"
[4]=>
string(6) "gopher"
[5]=>
string(4) "http"
[6]=>
string(5) "https"
[7]=>
string(4) "imap"
[8]=>
string(5) "imaps"
[9]=>
string(4) "ldap"
[10]=>
string(5) "ldaps"
[11]=>
string(4) "pop3"
[12]=>
string(5) "pop3s"
[13]=>
string(4) "rtsp"
[14]=>
string(3) "scp"
[15]=>
string(4) "sftp"
[16]=>
string(3) "smb"
[17]=>
string(4) "smbs"
[18]=>
string(4) "smtp"
[19]=>
string(5) "smtps"
[20]=>
string(6) "telnet"
[21]=>
string(4) "tftp"
}
["ares"]=>
string(0) ""
["ares_num"]=>
int(0)
["libidn"]=>
string(0) ""
["iconv_ver_num"]=>
int(0)
["libssh_version"]=>
string(13) "libssh2/1.4.2"
["brotli_ver_num"]=>
int(16777218)
["brotli_version"]=>
string(5) "1.0.2"
}
yum info php output:
Loaded plugins: fastestmirror, universal-hooks
Determining fastest mirrors
* EA4: 104.219.172.10
* cpanel-addons-production-feed: 104.219.172.10
* base: mirror.phx1.us.spryservers.net
* extras: repos-lax.psychz.net
* updates: centos4.zswap.net
EA4 | 2.9 kB 00:00 ...
cpanel-addons-production-feed | 2.9 kB 00:00 ...
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
nodesource | 2.5 kB 00:00
updates | 3.4 kB 00:00
yum info curl output:
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 104.219.172.10
* cpanel-addons-production-feed: 104.219.172.10
* base: mirror.phx1.us.spryservers.net
* extras: repos-lax.psychz.net
* updates: centos4.zswap.net
Installed Packages
Name : curl
Arch : x86_64
Version : 7.19.7
Release : 54.el6_10
Size : 349 k
Repo : installed
From repo : updates
Summary : A utility for getting files from remote servers (FTP, HTTP, and others)
URL : http://curl.haxx.se/
License : MIT
Description : cURL is a tool for getting files from HTTP, FTP, FILE, LDAP, LDAPS,
: DICT, TELNET and TFTP servers, using any of the supported protocols.
: cURL is designed to work without user interaction or any kind of
: interactivity. cURL offers many useful capabilities, like proxy support,
: user authentication, FTP upload, HTTP post, and file transfer resume.
Thanks @Gaffen. Could you also answer these 2 questions?
- Which hosting provider are you using? (e.g. Linode, DigitalOcean, etc.)
- Are you using cPanel / WHM? If so, which version?
No worries @ob-stripe,
Unfortunately I don't have access to the hosting provider account or information as I have delegated access. I will try to find out as soon as I can.
We are using both WHM and CPanel, version is 86.0.18