PHP fsockopenを介してサーバーに接続し、最初に基本認証用のCookieを取得してから、応答のLocationヘッダーで定義されたストリーミングサーバーに永続的に接続しようとしています。
問題は、私のコードがfgetsでフリーズし、宛先サーバーから応答データを受信しないことです。Amazonec2インスタンスのポート443でhttps経由で接続しています。サーバーは、サーバーのターミナルのcurlまたはchomeブラウザーを介して正常に接続します。
$this->conn = fsockopen('ssl://[destination_server]', 443, $errNo, $errStr, $this->connectTimeout);
stream_set_blocking($this->conn, 1);
fwrite($this->conn, "GET " . $urlParts['path'] . " HTTP/1.0\r\n");
fwrite($this->conn, "Host: " . $urlParts['host'] . "\r\n");
fwrite($this->conn, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($this->conn, "Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
fwrite($this->conn, 'Authorization: Basic ' . $authCredentials . "\r\n");
fwrite($this->conn, 'User-Agent: ' . self::USER_AGENT . "\r\n");
list($httpVer, $httpCode, $httpMessage) = preg_split('/\s+/', trim(fgets($this->conn, 1024)), 3);
//code never gets here!!!
何かご意見は?