1

预期结果:

从 SOAP 服务器接收数据时,连接将终止

实际结果:

在进行 SOAP 调用时,连接default_socket_timeout在最终终止之前一直保持打开状态直至最大值。我目前将其设置为 5 秒只是为了获得可靠的响应时间(这仍然很荒谬)

PHP 7.0.30-0ubuntu0.16.04.1 (cli)

我确信其中很多都是多余的,但我刚开始将所有东西都扔给构造函数,只是为了看看是否有什么东西会粘住。

$context = stream_context_create(
    array('http' =>
        array(
            'protocol_version' => '1.1',
            'header'           => 'Connection: close'
        )
    )
);

$this->_soap_client = new SoapClient($host_uri . '/api/' . MagentoSoap::V1_SOAP . '/?wsdl', array(
    'cache_wsdl'     => WSDL_CACHE_DISK,
    'keep_alive'     => false,
    'stream_context' => $context,
    'trace'          => 1
));

//HANGS HERE (and subsequent soap calls to php.ini's default_socket_timeout value)
$this->_soap_session = $this->_soap_client->login($this->_config['magento_api_credentials']['username'], $this->_config['magento_api_credentials']['password']);

示例请求/响应标头:

HTTP/1.1 200 OK
Date: Fri, 24 Aug 2018 15:53:41 GMT
Content-Type: text/xml; charset=UTF-8
Content-Length: 544
Connection: close
Set-Cookie: __cfduid=db509bea5b6140817d0ab01daef54d6141535126021; expires=Sat, 24-Aug-19 15:53:41 GMT; path=/; domain=.xxx.com; HttpOnly
Set-Cookie: PHPSESSID=62c4ff56a5ccc17b26700129a19636e1; expires=Wed, 24-Aug-2118 21:10:21 GMT; Max-Age=3155692600; path=/; domain=www.xxx.com; secure; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Strict-Transport-Security: max-age=31536000; includeSubDomains;
X-UA-Compatible: IE=Edge
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 44f6fe42ff88921e-EWR

POST /index.php/api/soap/index/ HTTP/1.1
Host: www.xxx.com
Connection: close
User-Agent: PHP-SOAP/7.0.30-0ubuntu0.16.04.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:Action"
Content-Length: 642
Cookie: __cfduid=d8a5d51205add299655b6ab5478d3b8e41535126399;PHPSESSID=a201c37d45c983ee121c3f5a4716b29f;

php.ini 的肥皂值:

root@middleware-production:~/middleware# php -r 'phpinfo();' | grep soap
/etc/php/7.0/cli/conf.d/20-soap.ini,
soap
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
4

0 回答 0