I attempting to connect to a server via PHP fsockopen to initially get a cookie for basic auth and then to persistently connect to a streaming server defined in the Location header of the response.
The problem is that my code freezes on fgets and never receives any response data from the destination server. I'm connecting via https on port 443 on an Amazon ec2 instance. The server connects fine via curl in my server's terminal or via my chome browser.
$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
");
fwrite($this->conn, "Host: " . $urlParts['host'] . "
");
fwrite($this->conn, "Content-type: application/x-www-form-urlencoded
");
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 . "
");
fwrite($this->conn, 'User-Agent: ' . self::USER_AGENT . "
");
list($httpVer, $httpCode, $httpMessage) = preg_split('/\s+/', trim(fgets($this->conn, 1024)), 3);
//code never gets here!!!
Any thoughts?