问题
I am writing a job processor to dequeue from Windows Azure Queue Storage using Azure PHP SDK. The job just try to fetch 32 messages in a batch, process them, and then delete the messages from the queue, and the repeat these steps. However, for each time I run the PHP script, the errors below is throw after the loop has run for exactly 27 times:
PHP Fatal error: Uncaught HTTP_Request2_MessageException: Malformed response: in /usr/share/php/HTTP/Request2/Adapter/Socket.php on line 1013
#0 /usr/share/php/HTTP/Request2/Adapter/Socket.php(1013): HTTP_Request2_Response->__construct('', true, Object(Net_URL2))
#1 /usr/share/php/HTTP/Request2/Adapter/Socket.php(136): HTTP_Request2_Adapter_Socket->readResponse()
#2 /usr/share/php/HTTP/Request2.php(939): HTTP_Request2_Adapter_Socket->sendRequest(Object(HTTP_Request2))
#3 /usr/share/php/WindowsAzure/Common/Internal/Http/HttpClient.php(262): HTTP_Request2->send()
#4 /usr/share/php/WindowsAzure/Common/Internal/RestProxy.php(141): WindowsAzure\Common\Internal\Http\HttpClient->send(Array, Object(WindowsAzure\Common\Internal\Http\Url))
#5 /usr/share/php/WindowsAzure/Common/Internal/ServiceRestProxy.php(86): WindowsAzure\Common\Internal\RestProxy->sendContext(Object(WindowsAzure\Common\Internal\Http\HttpCallContext))
#6 /usr/share/php/WindowsAzure/Common/Internal/ServiceRestProxy.php(125): WindowsAzure\Common\Internal\ServiceRestPr in /usr/share/php/HTTP/Request2/Response.php on line 215
Any Azure expert could help me?
回答1:
In order to bypass the connection limit for HTTPS on Azure Storage operations (including the storage query, or say a block blob chunked upload), you need to set the azure blob service connection string to http.
You can do something like this (pass in false before doing a multi-operation call):
function getBlobStorageProxy($secure = true) {
if ($secure) {
$connectionString = "DefaultEndpointsProtocol=https;AccountName=[AccountName];AccountKey=[AccountKey]";
} else {
$connectionString = "DefaultEndpointsProtocol=http;AccountName=[AccountName];AccountKey=[AccountKey]";
}
$this->serviceBuilder = ServicesBuilder::getInstance();
return $this->serviceBuilder->createBlobService($connectionString);
}
来源:https://stackoverflow.com/questions/25762907/windows-azure-php-queue-rest-proxy-limit