1

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?

2
  • I droped the amazon-ec2 tag because I'm pretty sure this is not related to that and it might scare some folks off. Can you confirm that you can use fsockopen() against some other https service on the web? Commented Apr 23, 2011 at 8:13
  • I actually was testing against a different server with no problems. It turns out that it is a header required by the destination server, and had nothing to do with ec2. Commented Apr 23, 2011 at 15:58

1 Answer 1

0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.