2014-09-10 77 views
1

我正在編寫一個作業處理器,使用Azure PHP SDK從Windows Azure隊列存儲中取出隊列。該作業只是嘗試在批處理中獲取32條消息,處理它們,然後從隊列中刪除消息,然後重複這些步驟。然而,每次我運行PHP腳本時,錯誤下面的循環之後投已經跑了整整27倍:Windows Azure PHP隊列REST代理限制

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 

任何Azure的專家能幫助我嗎?

+1

問題已經通過使用HTTP,而不是HTTPS作爲協議解決。應該由於HTTPS的連接限制。 – 2014-09-11 04:00:18

+0

此評論是正確答案;然而,如何實現這一點並不明顯。我想通了,並將其添加爲下面的答案。 – janson0 2014-11-08 21:03:41

回答

0

爲了繞過Azure存儲操作上的HTTPS連接限制(包括存儲查詢,或者說塊blob分塊上載),您需要將azure blob服務連接字符串設置爲http。

你可以做這樣的事情(假傳遞做多操作調用之前):

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); 
}