windows - 通过 WCF 的套接字连接协议 net.tcp 的问题
问题描述
对于以下所有用例,我都遇到了这种情况。除了情况 3 正常且一般,其余情况需要解决
以下这些服务正在运行,没有任何错误:
- Net.Msmq 侦听器适配器
- Net.Pipe 侦听器适配器
- Net.Tcp 侦听器适配器
- Net.Tcp 端口共享服务
- Windows 进程激活服务
还启用了协议:net.tcp,http
在调用 WCF 编写的服务时从命令行或通过应用程序:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools>svcutil net.tcp://localhost/TNA/TAServices/AuthenticationManager/mex
情况1:
Could not connect to net.tcp://localhost/TNA/TAServices/AuthenticationManager/mex. The connection attempt lasted for a time span of 00:00:04.0935290. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808. No connection could be made because the target machine actively refused it 127.0.0.1:808
案例二:
There was no endpoint listening at net.tcp://localhost/TNA/TAServices/AuthenticationManager/mex that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
案例3:
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:04:59.9843875'. An existing connection was forcibly closed by the remote host
案例 2 的事件日志:
An error occurred in the Activation Service 'NetTcpActivator' of the protocol 'net.tcp' while trying to listen for the site '1', thus the protocol is disabled for the site temporarily. See the exception message for more details.
URL: WeakWildcard:net.tcp://username.domainname.com/
Status: FailedToListen
Exception: System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:808. This could happen if there is another application already listening on this endpoint or if you have multiple service endpoints in your service host with the same IP endpoint but with incompatible binding configurations. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.ServiceModel.Channels.SocketConnectionListener.Listen()
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SocketConnectionListener.Listen()
at System.ServiceModel.Activation.TransportListener.Go(IConnectionListener connectionListener)
at System.ServiceModel.Activation.TransportListener..ctor(IPEndPoint endPoint)
at System.ServiceModel.Activation.TransportListener.Listen(IPEndPoint endPoint)
at System.ServiceModel.Activation.RoutingTable.TcpStart(MessageQueue messageQueue, BaseUriWithWildcard path)
at System.ServiceModel.Activation.MessageQueue.Register(BaseUriWithWildcard path)
at System.ServiceModel.Activation.ListenerAdapter.RegisterBindings(IActivatedMessageQueue queue, Int32 siteId, String[] bindings, String path)
Process Name: SMSvcHost
Process ID: 4608
我们应该如何实现默认情况下进入案例3,无论何时,例如引导和重新启动系统?
解决方案
Case 1
并且Case 2
需要 WCF 服务配置中的 Mex 服务端点。请添加一个 Mex 端点以交换服务元数据。
<system.serviceModel>
<services>
<service name="WcfService1.Service1">
<endpoint address="service1" binding="basicHttpBinding" contract="WcfService1.IService1" ></endpoint>
<endpoint address="service2" binding="netTcpBinding" contract="WcfService1.IService1"></endpoint>
<!--for exchanging service metadata.-->
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
如果有什么我可以帮忙的,请随时告诉我。
推荐阅读
- php - While循环在显示之前不等待
- asp.net-core - 是否可以从浏览器调用 blazor-server 函数
- c# - 具有自关闭/关闭标签能力的扩展 Html Link 类
- flutter - 颤振注射模拟
- amazon-cloudwatch - 如何摆脱“collect_GenericJMX_value”作为收集的自定义指标的 CW 指标名称?
- python - python列表中的字符串是用花括号写的
- firebase - 用于一对一消息传递的 Firebase 数据库结构?
- azure-active-directory - Azure AD:通过 AAD 在 jwt 令牌中缺少角色声明
- bash - 终端无法理解 Bash 脚本;权限被拒绝错误?
- woocommerce - Woocommerc 在管理员订单详细信息中重命名字段名称