我有一个使用.NET APIs的WordPress安装,托管在另一个服务器上。最近,我面临这样一个问题,我在Apache/Linux上的WordPress安装,在几个端点上不断地收到CURL错误56。在很多失败的调试之后,我搬到了Windows/IIS环境,在那里一切都很正常。
现在,突然间,我在Windows/IIS上也开始收到同样的错误。令人匪夷所思的是,我所调用的外部API都托管在同一台服务器上。但是,在这些API中,有几个工作正常,而其他的却出现了CURL错误56。
所以,比如说,如果我调用。
https://example.com/api/v5/Members/SignIn
这个工作正常。但是当我调用
https://example.com/api/v5/Members/VerifyDuplicateAccount
它突然以CURL错误代码56结束。我从curl_error
得到的错误信息如下。
OpenSSL SSL_read: Connection was reset, errno 10054
我已经浪费了好几天的时间来解决这个问题,但都失败了。我试着把php_curl更新到7.6.8,把PHP更新到7.4.4,但是到目前为止没有任何帮助。
这是我写的一个用于调试的测试脚本。
ob_start();
$out = fopen('php://output', 'w');
$_headers = array(
'Content-Type: application/json',
'Authorization: Bearer 5579PP5HSfZXjWZ9kpqEn9ST7BaWhTrcEUghL7Z_sRpGKXTmh40WxdfJ-9F7pe5LwHY9w0DH6v8r7HQrNke3JjonWwFRwTV-_8JEUuwudrKf6Ii1QSTGWtkaZ_GRZVWbN8eUh5BzPnRnzF8JQ_Goq_dx0cXQYqewQHG7iAU1aSifatwbAZLY-h_GGBTnJ72uZ6ZNix8E-7Th4Pftrpqx5bytay0fY1ES5ppuqDn4h-9TakZEedwnpzup30ApphTGGQxYAGrkRArEj0nXXV2yH8lHUL8SrZJKc9SGaE8y6qtxQc_F50imU-f8fb5P2WSNaPeYEaYJ2o6dj1r7A9VuiabCxMsdAzIFvlyPSrcdpGO1uBRoTVwVBMmH7prpFRzKWYrX69BF-IET4rN8POT1Zg',
'Expect: '
); //print_r($_headers);
$params = '{"OwnerDescription":"myOwner","UserAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/80.0.3987.149 Safari\/537.36","VendorKey":"abc123","address":{"HomeAddress":{"CountryCode":"US","StateProvinceAbbrevation":"GA","Line1":"Test ADDRESS","City":"ATL","PostalCode":"30003"},"MailingAddress":{"CountryCode":"US","StateProvinceAbbrevation":"GA","Line1":"Test ADDRESS","City":"ATL","PostalCode":"30003"},"BillingAddress":{"CountryCode":"US"}},"contactInfo":{"PrimaryContactNumber":"1234334444","Email":"xyzm@gmail.com"},"membership":{"Members":[{"FirstName":"Osama","MiddleName":"","LastName":"Trankler","ParticipantType":"Primary","Gender":"NotAvailable","DateOfBirth":"11\/12\/1998"}],"EffectiveDate":"04\/08\/2020","Term":null,"TermLength":null,"PlanName":"ABC"}}';
$curl = curl_init();
$url = 'https://example.com/api/v5/Members/VerifyDuplicateAccount';
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $_headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($curl, CURLOPT_TIMEOUT, 600);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
if ($response = curl_exec($curl)) {
} else {
$response = curl_error($curl);
echo 'curl_error=>'.curl_errno($curl);
@curl_close($curl);
fclose($out);
$debug = ob_get_clean();
echo 'debug=> '.$debug;
print_r($response);
这里是我得到的响应。
* Trying 199.1.1.1:443...
* TCP_NODELAY set
* Connected to example.com (199.1.1.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: C:\curl_cert\cacert.pem
CApath: none
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=Texas; L=Lewisville; O=ABC Holdings LLC
T; CN=*.example.com
* start date: Nov 13 00:00:00 2019 GMT
* expire date: Nov 17 12:00:00 2021 GMT
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Hig
rance Server CA
* SSL certificate verify ok.
> PUT /api/v5/Members/VerifyDuplicateAccount HTTP/1.1
Host: example.com
Accept: */*
Content-Type: application/json
Authorization: Bearer 5579PP5HSfZX
Content-Length: 1023