I am 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.
Is there an outbound firewall setting that I'm missing on ec2? I've even opened up the inbound 443 port on the server, but of course that seems pointless.
Any thoughts?
I solved this problem by adding the header: "Connection: Close\r\n\r\n".
The initial request for the cookie returns a 302 redirect code and will sit on the open connection unless you pass that header.
Unfortunately, this little line had me stumped for a while.