Question

So, we have a large program which uses HttpListener for a small remote admin feature. For reasons I don't understand, some people have issues with a 503 error.

Since we're not supplying the error, there's something happening in the framework. Now, my question is, what inside the framework supplies this error? Is it that the prefixes aren't set properly or something?

We currently have our prefix set as "http://*:8080/".

Advice?

Was it helpful?

Solution

I've got same error on Windows 7, when trying to set permissions for HttpListener using netsh http command. On target system run the command (valid for Windows 7):

netsh http show urlacl    

and check, if your URL "http://+:8080/" already presented in reserved urls list. Try to remove from list (using "netsh http delete urlacl". Similar topic here.

OTHER TIPS

I'm a bit late to the question. But I just faced the HTTP 503 status code in the following case:

If, for example, there is "http://+:8080/MyService/" and "http://+:8080/MyService/SOAP" registered using netsh http add urlacl, we receive 503 for requests targeting an ambiguous URL. Requests for "http://myservice:8080/MyService/somethingelse" worked fine, while requests for "http://myservice:8080/MyService/SOAP/" failed with status 503.

Added this for completeness. Took me a while to figure out.

Make sure your HttpListener and urlacl match.

Starting your listener as (C#):

using System;
using System.Net;
using System.ServiceModel;

namespace Example
{
    class MyApi
    {
        private const int _apiPortNumber = 8080;
        public const string BasePath = "/myApi/";
        public static EndpointAddress MyEndPoint => new EndpointAddress(
            new UriBuilder(
                    Uri.UriSchemeHttp,
                    "localhost",//only allow connections on localhost (no remote access)
                    _apiPortNumber,
                    BasePath)
                .Uri);

        public MyApi()
        {
            var httpListener = new System.Net.HttpListener();
            httpListener.Prefixes.Add(MyEndPoint.Uri.ToString());
            httpListener.Start();
        }
    }
}

What works as your urlacl is:

netsh http add urlacl url=http://127.0.0.1:8080/myApi/ user=MyServiceUserName

However configuring your urlacl as follows will NOT work:

http add urlacl url=http://+:8080/myApi/ user=MyServiceUserName

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top