Writing web applications that register with “urlacl”

Minor rant here, but I’ve been developing some web applications lately, and a common reoccurring exception that threw my testing into limbo is something to the affect of

URL Reservation failed: System failed to make the required URL reservation

What does this mean? Well, let’s dive into this and figure it out.

Situation 1: Normal server application

In a normal server application, you as a programmer tell the socket library to listen, and you give it a port and ip range in which to listen for connections on. The application will then proceed to try and listen on that port. Assuming no other applications are also listening on that port, it listens. Connections from clients are picked up, your application can handle them and you move on with no issues.

Some things you need to setup to make this work:

  • Firewall rules
  • Port forwarding (if applicable)
  • Ensure nothing else is listening on that port

Not too hard, it makes sense, and is pretty universal in that you’ll have these issues regardless of the operating system you’re running.

Situation 2: ‘Web Application’ using Microsoft OWIN

In this situation, you give the application a url you want to listen on that includes port. It could be http://192.168.0.1:80/ to listen only from 192.168.0.1, or something like http://+:80/ to listen on all interfaces and addresses. Ok, cool. Seems pretty straight forward. You setup some routes, everything looks like it’s good to go. Let’s hit debug on the application.

URL Reservation failed: System failed to make the required URL reservation

O..kay. Diving through tons of Microsoft and stack overflow articles about this, there is mention of http.sys, various netsh commands, some graphical manager for these that is exclusive to windows server operating systems, and of course more mention of URL reservations.

After some digging, I finally stumbled upon this: Http Server API

Applications that throw errors like this are utilizing a Microsoft API that allows applications to handle HTTP without having to write their own handler for the HTT Protocol. However, to use this, you must ‘reserve’ the url you wish to handle requests on. This does require however, removing any preexisting reservations for your url, which if you have an application installed that is really dependent on it, you could break things terribly. It’s not even just that, but if there is a url reserved for the same port as yours, even if it is a different address, you cannot add your own reservations. So with that, we have…

Setup steps required for this to work:

  • Firewall rules
  • Port forwarding (if applicable)
  • Ensure no one else is listening on that port
  • Ensure there are no other url reservations on that port (netsh http show urlacl in command line)
  • Add your own url reservation (netsh http add urlacl http://+:80/ in command line)

 

 

So now we know why urlacls are needed, some commands to use to add and show them, and some good reasoning to use an actual web server.

Leave a Reply

Your email address will not be published. Required fields are marked *