PHP 7.0 / SOAP无法关闭具有适当标头的连接

时间:2018-08-24 16:18:11

标签: php soap php-7 soap-client php-7.0

预期结果:

从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

0 个答案:

没有答案