假设一个提升的用户(例如安装程序)配置一个 URL 预留:
netsh http add urlacl url="https://+:8105/" user="SVCACCOUNT" listen=yes
现在当 Owin 启动(在 SVCACCOUNT 下运行)时,会出现以下错误:
System.Net.HttpListenerException: Failed to listen on prefix 'http://+:8105/' because it conflicts with an existing registration on the machine.
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(..)
at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(..)
...
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
和 Owin 的“入口”点:
WebApp.Start("http://+:8105", ..)
在创建问题期间,我发现
http://*:8105
的注册和相同“工作”的 Owin/HttpListener URL。*
(“弱通配符”)在注册和绑定(bind)中都允许监听器启动? (使用“强通配符”会引发上述错误;完全删除注册将导致监听器因帐户访问受限而失败并显示“访问被拒绝”。)这在哪里记录,从强通配符切换到弱通配符的修复有什么“后果”?为什么这个修复甚至有效?从多次提出相关问题(通常没有很好的答案)来看,似乎
+
过去和/或在不同的系统或配置上“可能有效”:发生了什么变化?(我发现关于 http.sys 配置的零散文档,例如 Host-Specifier Categories 虽然仍然没有明确解释“冲突注册”。)
如果根据 System.Net.HttpListenerException: Failed to listen on prefix 'http://localhost:8080 删除注册Owin服务启动成功。但是我相信这需要更高的海拔来监听端口。
这不是“Owin self-host - Failed to listen on prefix 'http://localhost:12345/' because it conflicts with an existing registration on the machine”的重复,因为只有在定义了 URL 保留时才会出现问题:此外,没有其他进程正在监听,正如通过 netstat 确认的那样。
像 Self hosted OWIN and urlacl 这样的问题让我相信这要么是权限问题,要么是微不足道的问题。例如,
http://+:port
如何不同于 http://*:port
? (不,使用 'EVERYONE' 作为 urlacl 并不能解决问题。)“Running self-hosted OWIN Web API under non-admin account ”中的注释可能是相关的 - 与
+
相关。对比 *
..和普遍缺乏澄清。
最佳答案
- What prevents HttpListener (and thus Owin) from using the registrations previously taken with a Strong Wildcard?
也许问题是您正在注册 HTTPS
协议(protocol):
netsh http add urlacl url="https://+:8105/" user="SVCACCOUNT" listen=yes
然后你使用 HTTP
代码中的协议(protocol):WebApp.Start("http://+:8105", ..)
-Why does using * (a "weak wildcard") in both registration and binding allow a listener to start?
*
之间的区别和 +
通配符是 *
包括 void 元素和 +
强制存在至少 1 个字符。我不知道执行差异,但可能是一个几乎无法察觉的微小差异。
关于c# - 为什么在监听强通配符(http ://+:port) http. sys/urlacl 绑定(bind)时 HttpListener "conflict with an existing registration"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46859026/