Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I bind to both public IP and localhost with AppHostHttpListenerBase

Tags:

servicestack

I have created a ServiceStack Windows service which runs an AppHostHttpListenerBase. I can get it to listen for remote requests by listening on the private IP address of the server (e.g. http://1.2.3.4:8080/. In such cases, I can consume the services across the Internet using the server's public IP address, but requests executed on the server to http://localhost:8080/ fail.

If I change the binding address to http://*:8080/, then requests to localhost succeed, but I can no longer access the server across the Internet; I get a 503 Service Unavailable.

Any ideas how I can have my web services listen to both local requests and requests across the Internet?

And, just as importantly, why is it that when loosening the restriction on the listening address from a specific IP to a * do requests across the Internet suddenly start to fail?

like image 348
Richard Fawcett Avatar asked Aug 19 '13 14:08

Richard Fawcett


1 Answers

It could be that some other listener is already handling the request, and the * only matches those not handled. I would just try to listen to http://+:8080/ in the hope that it helps. For further information on HttpListenerPrefix see https://msdn.microsoft.com/en-us/library/system.net.httplistenerprefixcollection.add(v=vs.110).aspx

like image 141
Tobias Avatar answered Oct 11 '22 14:10

Tobias