【发布时间】:2017-02-17 08:03:48
【问题描述】:
我在使用 net.tcp 端点启动 WCF 服务时遇到问题。我收到 10049 错误。
我的app.config:
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehaviour0"
name="Tinkl.Server.Services.Authentication.AuthenticationService">
<endpoint name="httpEndpoint"
address="reg"
binding="basicHttpBinding"
contract="Tinkl.Server.Services.Authentication.IRegistrationService" />
<endpoint name="httpEndpoint"
address="auth"
binding="basicHttpBinding"
contract="Tinkl.Server.Services.Authentication.IAuthorizationService" />
<!--
<endpoint name="tcpEndpoint"
address="net.tcp://78.26.210.203:50050/reg"
binding="netTcpBinding"
contract="Tinkl.Server.Services.Authentication.IRegistrationService" />
<endpoint name="tcpEndpoint"
address="net.tcp://78.26.210.203:50051/auth"
binding="netTcpBinding"
contract="Tinkl.Server.Services.Authentication.IAuthorizationService" />
-->
<endpoint name="mexEndpoint"
address="mex"
binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://78.26.210.203:50076/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour0">
<!--<serviceMetadata />-->
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
netTcpBinding 有 2 个端点,basicHttpBinding 有 2 个完全相同。
当我尝试使用netTcpBinding 端点时出现问题,我收到错误消息,但使用basicHttpBinding 可以正常工作...
我在控制台应用程序中托管 WCF 服务。
程序代码
ServiceHost authenticationHost = new ServiceHost(typeof(AuthenticationService));
authenticationHost.Open();
Console.WriteLine("close <ENTER>\n");
Console.ReadLine();
authenticationHost.Close();
也许有人遇到过类似的问题?
如果需要,我会提供所有必要的附加信息
提前谢谢你!
【问题讨论】:
-
根据异常,您在 tcp 侦听器上遇到错误。侦听器不应侦听 IP 地址。您应该正在收听端点 IP.Any。
-
@jdweng,你能举个例子吗?
-
查看网页:stackoverflow.com/questions/32181993/…。程序代码可能正在启动侦听器。对于套接字代码示例,请参见以下内容:您可以使用任何继承套接字的类,例如 TCPListener,而不是套接字:msdn.microsoft.com/en-us/library/w89fhyex(v=vs.110).aspx