首先,我不擅长WCF。 我在 WindowsService 中托管了一个 WCF 服务。 由于有时服务因异常而停止运行:
HTTP 无法注册 URL http://+:8092/MyService/因为 TCP 端口 8092 正在被另一个应用程序使用。
- 没有任何东西使用这个端口,它对我尝试过的任何端口都是一样的。
- 已配置 SSL 证书。
有很多机器可以启动这个服务,但是最需要的(客户的)机器不能。 我在本网站或其他任何地方看到很多帖子,但找不到解决方案。 我从来没有看到过像“它帮助了我”这样的帖子。 我已经卡住了好几天了,请帮忙。
配置文件中的数据下方:
<system.serviceModel>
<services>
<service name="MyCompany.MyApp.MyAppService" behaviorConfiguration="MetadataSupport">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8092/MyAppService" />
<add baseAddress="net.tcp://localhost:8093/MyAppService" />
<add baseAddress="net.pipe://localhost/" />
</baseAddresses>
</host>
<endpoint binding="wsDualHttpBinding" contract="MyCompany.MyApp.IMyAppService" />
<endpoint binding="netTcpBinding" contract="MyCompany.MyApp.IMyAppService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="tcpmex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataSupport">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True" httpGetUrl="" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug httpHelpPageEnabled="True" includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
最佳答案
您正在通过 wsDualHttpBinding
使用 WCF 双工通信。在这种情况下,WCF 在端口 8092 上创建一个 HTTP 套接字来为客户端回调 提供服务。显然客户端与 IIS 5.X 冲突。 (我猜你有 XP 和 IIS 5.x)
要解决此问题,您必须在客户端的绑定(bind)配置中提供一个 clientBaseAddress
并指定一个不同的端口。
示例客户端配置:
我希望这确实是您机器的问题,请将此解决方案的结果通知我。
祝你好运:-)
关于wcf - HTTP 无法注册 URL ... 因为 TCP 端口 ... 正在被另一个应用程序使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7572305/