當長輪詢天青隊列存儲與天青-SDK換PHP,如果我的請求是超過30秒開,所述庫與此錯誤模具:輪詢天青隊列返回管道中斷
PHP Notice: fwrite(): send of 277 bytes failed with errno=32 Broken pipe in ..../vendor/pear-pear.php.net/HTTP_Request2/HTTP/Request2/SocketWrapper.php on line 188
如果我將睡眠函數設置爲30秒,那麼所有事情都會很好,但是我正在做很多我不需要的請求。
我的工人代碼:
use WindowsAzure\Common\ServicesBuilder;
use WindowsAzure\Common\ServiceException;
Class Worker_Task {
public $queueRestProxy;
public $servicesBuilder;
public $connectionString;
public function __construct() {
$this->connectionString = Config::get('azure.connection_string');
$this->servicesBuilder = ServicesBuilder::getInstance();
$this->queueRestProxy = $this->servicesBuilder->createQueueService($this->connectionString);
}
public function emails() {
$this->write('Processing mails...');
while(true) {
$this->queueRestProxy = $this->servicesBuilder->createQueueService($this->connectionString);
// Get message.
$listMessagesResult = $this->queueRestProxy->listMessages("emails");
$messages = $listMessagesResult->getQueueMessages();
foreach($messages as $message) {
// Process Message
$content = json_decode($message->getMessageText());
// Dispatch Email
// Delete Job
$this->deleteJob('emails', $message->getMessageId(), $message->getPopReceipt());
}
sleep(30);
}
}
}
什麼是/SocketWrapper.php的180-200行? – Abela 2013-04-07 03:05:02
@Yhanhannan他們正在使用PEAR軟件包(HTTP_Request2)。我用你所要求的幾行創建了一個要點:https://gist.github.com/fedeisas/5331164#file-socketwrapper-php-L175。 Thanks1 – fedeisas 2013-04-07 16:21:29