Wcf HTTP无法注册URL。。。因为TCP端口。。。正在被另一个应用程序使用
首先,我不擅长WCF。 我在WindowsService中托管了一个WCF服务。 由于出现异常,服务停止运行: HTTP无法注册URL,因为另一个应用程序正在使用TCP端口8092Wcf HTTP无法注册URL。。。因为TCP端口。。。正在被另一个应用程序使用,wcf,http,wcf-binding,Wcf,Http,Wcf Binding,首先,我不擅长WCF。 我在WindowsService中托管了一个WCF服务。 由于出现异常,服务停止运行: HTTP无法注册URL,因为另一个应用程序正在使用TCP端口8092 没有任何东西使用这个端口,我尝试的任何端口都是一样的 已配置SSL证书 有许多机器可以启动此服务,但最需要的(客户的)机器不能。 我在这个网站或其他任何地方看到了许多帖子,但找不到解决方案。 我从来没有看到过像“它帮助了我”这样的帖子。 我已经困了好几天了,请帮帮我 下面是配置文件中的数据: <system
- 没有任何东西使用这个端口,我尝试的任何端口都是一样的
- 已配置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>
尝试以具有管理员权限的用户身份运行windows服务。某些版本的Windows(2008/Vista及以上)对谁可以打开端口很挑剔。如果这有帮助的话,那么您当然不想以管理员的身份实际运行该服务,但它至少为您指明了权限的方向
此外,您提到了SSL证书,但它是一个“http”url,而不是“https”。这似乎不寻常。我建议执行以下诊断步骤: 尝试以自主机方式托管WCF服务(控制台应用程序):
- 使用类
HttpServiceHost
- 使用此绑定:
var binding=newhttpbinding(HttpBindingSecurityMode.Transport)代码>
AddServiceEndpoint(typeof(YourServiceClass),绑定,”https://url...");代码>
让我知道您的结果:-)您正在与
wsDualHttpBinding
使用WCF双工通信。在这种情况下,WCF在端口8092上创建一个HTTP套接字,为客户端回调提供服务。很明显,客户端与IIS 5.X冲突。(我猜你有XP和IIS 5.x)
要解决此问题,必须在客户端的绑定配置中提供clientBaseAddress
,并指定其他端口
客户端配置示例:
我希望这确实是您的机器中的问题,请将此解决方案的结果通知我
祝你好运:-)控制台代码也得到了同样的异常:
Type-serviceType=typeof(MyService);ServiceHost主机=新的ServiceHost(serviceType)//var binding=新的WSDualHttpBinding();var binding=新的WSHttpBinding();host.AddServiceEndpoint(typeof(IMyService),binding“”);host.Open();我根据您的配置制作了示例应用程序(控制台),它对我有效。我需要知道您的计算机中是否安装了IIS。