{"id":43,"date":"2005-08-19T15:54:03","date_gmt":"2005-08-19T22:54:03","guid":{"rendered":"http:\/\/kennyw.com\/indigo\/43"},"modified":"2005-08-19T15:54:03","modified_gmt":"2005-08-19T22:54:03","slug":"dealing-with-http-port-conflicts-on-xpsp2","status":"publish","type":"post","link":"https:\/\/kennyw.com\/?p=43","title":{"rendered":"Resolving conflict: Http ports and XPSP2"},"content":{"rendered":"<p>A giant leap forward in Windows HTTP technologies was introduced with Windows Server 2003, namely <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/http\/http\/http_api_start_page.asp\">http.sys<\/a>.  Http.sys includes a kernel-mode listener that can dispatch to any process on the machine.  This was great news to those of us that wanted to share port 80 with other applications (IIS for example).  It also has a comprehensive <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/http\/http\/namespace_reservations_registrations_and_routing.asp\">namespace security mechanism<\/a> which admins can use to delegate sections of the global hierarchical directory space to less-privileged accounts.   IIS 6.0 (which shipped with Server 2003)  was built on top of http.sys and so did not require exclusive access to its configured port #s.<\/p>\n<p>Indigo&#8217;s standalone HTTP IChannelListeners are built on top of http.sys.  That means that if you are not hosted in IIS, your process will need to have access to any http addresses that your ServiceHost is configured with.  If the process is not running as admin you will need to add a reservation using <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/http\/http\/httpcfg_exe.asp\">httpcfg.exe<\/a>. Alternatively, you can call the HTTP <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/http\/http\/configuration_apis.asp\">configuration APIs<\/a>, such as <a href=\"http:\/\/msdn.microsoft.com\/library\/default.asp?url=\/library\/en-us\/http\/http\/httpsetserviceconfiguration.asp\">HttpSetServiceConfiguration<\/a>, directly.<\/p>\n<p>There is one more wrinkle when working on XPSP2.  While http.sys was backported to XP as part of Service Pack 2 (yay), IIS 6.0 was not (boo).  This means that if you have IIS running on your XP box, then you are using IIS 5.1 which is built on top of a listening socket and thus owns port 80.  If you try to open a Service using port 80 while IIS is running you will get the following error:<\/p>\n<blockquote><p><code>AddressAlreadyInUseException: HTTP could not register URL http:\/\/+:80\/myService\/ because TCP port 80 is being used by another application.<\/code><\/p><\/blockquote>\n<p>You have 2 choices to remedy this situation:<\/p>\n<ol>\n<li>Stop IIS (using &#8220;net stop w3svc&#8221;)<\/li>\n<li>Setup your service to use a different port#<\/li>\n<\/ol>\n<p>Setting up a different port# is usually a simple matter of changing your Service&#8217;s URL.  However, a more subtle variation of this failure occurs for clients that use WsDualHttpBinding (or a custom binding with CompositeDuplexBindingElement and HttpTransportBindingElement).  Your indication here is the inclusion of &#8220;Temporary_Indigo_Addresses&#8221; as in:<\/p>\n<blockquote><p><code>AddressAlreadyInUseException: HTTP could not register URL http:\/\/+:80\/Temporary_Listen_Addresses\/51E705D5-E7B5-472B-B6B9-A6A60FE93B7A\/ because TCP port 80 is being used by another application.<\/code><\/p><\/blockquote>\n<p>When your client is using a Dual binding, then the system creates a temporary address to listen on, in order to establish two-way communication over two one-way channels.  For HTTP, this address by default is setup on a subtree of http:\/\/+:80\/Temporary_Indigo_Addresses.  This has the advantage of being a namespace pre-ACLed by Indigo for access by all processes.  You can override this default through the ClientBaseAddress property on WsDualHttpBinding and CompositeDuplexBindingElement.  You can do this either through code:<\/p>\n<blockquote><p><code>binding.ClientBaseAddress = \"http:\/\/localhost:8000\/myClient\/\"<\/code><\/p><\/blockquote>\n<p>or config:<\/p>\n<blockquote><p><code>&lt;wsDualHttpBinding clientBaseAddress=\"http:\/\/localhost:8000\/myClient\/\"\/&gt;<\/code><\/p><\/blockquote>\n<p>Good luck on future port conflict avoidance!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A giant leap forward in Windows HTTP technologies was introduced with Windows Server 2003, namely http.sys. Http.sys includes a kernel-mode listener that can dispatch to any process on the machine. This was great news to those of us that wanted to share port 80 with other applications (IIS for example). It also has a comprehensive [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-43","post","type-post","status-publish","format-standard","hentry","category-indigo"],"_links":{"self":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/43","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=43"}],"version-history":[{"count":0,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}