Welcome

首页 / 软件开发 / WCF / WCF分布式开发常见错误解决(11)

WCF分布式开发常见错误解决(11)2011-03-31 博客园 Frank Xu LeiWCF分布式开发常见错误解决(11):There is already a listener on IP endpoint ,IP 终结点 已经存在侦听器

进行WCF服务终结点配置的过程中,当你配置服务终结点端口,启动服务程序的时候会遇到如下错误,服务无法启动,1.错误信息如下:

IP终结点(端口) 0.0.0.0:8002已经存在一个侦听器,请确保程序中没有多次使用一个终结点,或别的程序没有监听此终结点(端口)

There is already a listener on IP endpoint 0.0.0.0:8002. Make sure that you are not trying to use this endpoint multiple times in your application and that there are no other applications listening on this endpoint.

2.原因:此端口已经被使用,即已经有程序在使用一个相同的端口所致。必须我们配置两个服务终结点使用一个终结点端口

<endpoint address="http://localhost:8002/WCFService" binding="wsHttpBinding" contract="WCFService.IWCFService">
</endpoint>
<endpoint
address="net.tcp://localhost:8002/WCFService"
binding="netTcpBinding" bindingName="netTcpBinding"

contract="WCFService.IWCFService">
</endpoint>

运行服务程序就会出现错误。

3.解决办法:

(1)检查机器的端口,确保此端口不是系统服务端口,或者没被其他程序使用。

(2)检查服务终结点配置信息,确保两个不同的服务使用不同的终结点端口

此例中的修改代码改为端口8001即可:

<endpoint
address="http://localhost:8001/WCFService"
binding="wsHttpBinding"
contract="WCFService.IWCFService">
</endpoint>