1

Same situation as this question, HttpListener not receiving remote requests, even with the firewall down and all prefixes registered, namely:

  • the HttpListener is only receiving requests from the same machine
  • the application is running on a Windows EC2 instance (same spec as the other question)
  • the ports being used are registered and opened in the firewall (I also temporarily took down the firewall to ensure that wasn't the issue)
  • The prefix I'm using is http://*:8080/

Differences from the other question:

  • The security groups of the EC2 are correctly configured
  • It was accepting outside requests, until (as far as I know) today and I'm not aware of any system changes (but I'm open to all ideas, whatsoever)

Additional info:

  • The EC2 instance and system is passing all status checks
  • I restarted the instance; no change
  • The http status code sent back (not from my server application, from the system) to a remote client is a 503 (service unavailable)
  • I've checked and rechecked that the url is correct (I have an elastic IP address and am using the public DNS of the instance in the url)
  • I ran netstat to make sure the port was not being used by other processes

Any ideas for things to check or try are completely welcome; I've pretty much run out of ideas...

Community
  • 1
  • 1
user1309279
  • 23
  • 1
  • 5
  • Can you post some of the code? There's a chance you're listening on the internal interface only (`localhost`) and therefore remote requests are not coming through. – yamen May 01 '12 at 03:53
  • Unfortunately, I can't post the code due to a NDA, but it's listening on http://*:8080/ - is that what you were recommending I check or something else? – user1309279 May 01 '12 at 04:03
  • If it responds to local requests but not to remote requests, then the problem is likely with the firewall or other security apparatus, not the `HttpListener`. – Jim Mischel May 01 '12 at 07:28
  • The appropriate firewall ports are open; to verify it wasn't a firewall issue, I turned it off - no change. Also the EC2 security groups are configured appropriately (I've checked and re-checked that as well). – user1309279 May 01 '12 at 15:51

2 Answers2

7

If you have more than one urlacl on the same port, e.g. like:

$ netsh http show urlacl

Reserved URL            : http://+:8080/
    User: PUBEN\myself
        Listen: Yes
        Delegate: No
        SDDL: D:(A;;GX;;;S-1-5-21-436374069-1547161642-1177238915-5114)

Reserved URL            : http://192.168.47.120:8080/
    User: \Everyone
        Listen: Yes
        Delegate: No
        SDDL: D:(A;;GX;;;WD)

Reserved URL            : http://127.0.0.1:8080/
    User: \Everyone
        Listen: Yes
        Delegate: No
        SDDL: D:(A;;GX;;;WD)

You will get ServiceUnavailable due to the first reservation in the list. To fix,

netsh http delete urlacl url=http://+:8080/

Or just use Suave.io and save yourself the headache.

Henrik
  • 9,714
  • 5
  • 53
  • 87
2

Couple of thoughts, some you've likely already checked:

  • Make sure you can still hit the listener locally on the machine - just to factor out something wrong with the code iteself

  • Make sure there is nothing else running on that port on that machine

  • Check the event viewer - any errors in there that may apply? Other events? A recent Windows Update - anything?

  • Try another port - to rule out port conflicts, try a different one

  • Make sure you are bound to the prefix: http://*:{your-port-#-here}/ - also, when you make your call HttpListener can be very specific, if you include a trailing slash in the prefix you register make sure you include that in your call, etc.

  • When you try to hit the machine - what address are you using: an EC2 Elastic IP address, the EC2 public dns, some DNS name you have routed to that machine? I have seen EC2 machines change public IP/DNS after a reboot before, maybe yours has changed?

That's all I can think of for now. Good luck.

brendan
  • 29,308
  • 20
  • 68
  • 109
  • I did check most of those things, but great checklist nonetheless! I hadn't tried other ports because there appeared to be no other processes using 8080 each time I ran netstat, but I followed your suggestion and added ports 8081 and 8082 and both local and remote traffic is getting through to the listener through them. Any ideas as to why it suddenly stopped working for 8080 even though it's registered, open in the firewall, there appear to be no conflicts, etc. ? – user1309279 May 01 '12 at 19:27
  • Try running netstat to see what ports are in use: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/netstat.mspx?mfr=true – brendan May 01 '12 at 19:40