加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

win7上的WCF Duplex net.tcp问题

发布时间:2020-12-14 05:29:16 所属栏目:Windows 来源:网络整理
导读:我们有一个WCF服务,有多个客户端来安排客户端之间的操作.它在XP上运行得很好.转到win7,我只能将客户端连接到同一台机器上的服务器.在这一点上,我认为它与IPv6有关,但我对如何继续下去感到困惑. 尝试连接到远程服务器的客户端提供以下异常: System.ServiceMo
我们有一个WCF服务,有多个客户端来安排客户端之间的操作.它在XP上运行得很好.转到win7,我只能将客户端连接到同一台机器上的服务器.在这一点上,我认为它与IPv6有关,但我对如何继续下去感到困惑.

尝试连接到远程服务器的客户端提供以下异常:

System.ServiceModel.EndpointNotFoundException: Could not connect to net.tcp://10.7.11.14:18297/zetec/Service/SchedulerService/Scheduler. The connection attempt lasted for a time span of 00:00:21.0042014. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time,or established connection failed because connected host has failed to respond 10.7.11.14:18297. —> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time,or established connection failed because connected host has failed to respond 10.7.11.14:18297

该服务配置如下:

<system.serviceModel>
  <services>
     <service
         name="SchedulerService"
         behaviorConfiguration="SchedulerServiceBehavior">
        <host>
           <baseAddresses>
              <add baseAddress="net.tcp://localhost/zetec/Service/SchedulerService"/>
           </baseAddresses>
        </host>
        <endpoint address="net.tcp://localhost:18297/zetec/Service/SchedulerService/Scheduler"
                  binding="netTcpBinding"
                  bindingConfiguration = "ConfigBindingNetTcp"
                  contract="IScheduler" />
        <endpoint address="net.tcp://localhost:18297/zetec/Service/SchedulerService/Scheduler"
                  binding="netTcpBinding"
                  bindingConfiguration = "ConfigBindingNetTcp"
                  contract="IProcessingNodeControl" />
     </service>
  </services>
  <bindings>
     <netTcpBinding>
        <binding name = "ConfigBindingNetTcp" portSharingEnabled="True">
           <security mode="None"/>
        </binding>
     </netTcpBinding >
  </bindings>

  <behaviors>
     <serviceBehaviors>
        <behavior name="SchedulerServiceBehavior">
           <serviceDebug includeExceptionDetailInFaults="true" />
           <serviceThrottling maxConcurrentSessions="100"/>
        </behavior>
     </serviceBehaviors>
  </behaviors>
</system.serviceModel>

客户端连接如下:

String endPoint = "net.tcp://" + GetIPV4Address(m_SchedulerHostAddress) + ":" + m_SchedulerHostPort.ToString(CultureInfo.InvariantCulture) + "/zetec/Service/SchedulerService/Scheduler";

NetTcpBinding binding = new NetTcpBinding();
binding.Security.Mode = SecurityMode.None;

m_Channel = new DuplexChannelFactory<IProcessingNodeControl>(this,binding,endPoint);
m_IProcessingNodeControl = m_Channel.CreateChannel();

我已经检查过我的防火墙十几次了,但我想我可能会遗漏一些东西.尝试禁用Windows防火墙.我尝试将localhost更改为我的ipv4地址以尝试远离ipv6,我尝试删除任何反ipv6代码.

不知道它是否意味着什么,但是:

Microsoft Telnet> open 10.7.11.14 18297
Connecting To 10.7.11.14…Could not open connection to the host,on port 18297:
Connect failed

遗憾的是,telnet测试似乎并不重要.当服务运行时,我已成功从localhost和远程计算机连接到我的服务端口,但我的客户端无法从远程计算机工作.

看起来并不总能保证连接到localhost.桌面(win7 / 32)工作,笔记本电脑(win7 / 64)不起作用.其他win7 / 64盒子确实有效.也许是因为笔记本电脑上有多个网卡?也没有解释在测试人员系统上连接的失败.

我设置了两台完全禁用IPv6的win7机器(使用0xffffffff,如http://support.microsoft.com/kb/929852所示).没有帮助.

解决方法

有关您的主机基地址和终点地址的内容不正确.一个有明确的端口引用,另一个没有.通常,当您使用基址时,在端点地址中使用相对URL.

我想不出为什么这会与IPv6有关,因为没有错误消息提到IPv6地址.

也许在禁用net.tcp端口共享选项后再试一次.没有端口共享,您应该能够像使用telnet一样使用telnet来连接连接.

另外,您的服务如何在Win7中托管?在IIS7中还是在Windows服务中自托管?在服务中托管它可能需要一些权限才能在您的防火墙上打开端口之外授予您的exe(就像您有时必须在Win XP中使用HTTP托管Windows服务一样).

对不起,我赶时间,无法查找这些网址.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读