【问题标题】:WCF initialization on local network hangs for 20 secs本地网络上的 WCF 初始化挂起 20 秒
【发布时间】:2013-09-18 09:01:49
【问题描述】:

我有使用 basicHttpBinding 的 WCF 服务。

当客户端和服务器在同一个网络上时,他们的初始调用会挂起大约 30 秒而不是顺利。

当我通过互联网从客户端使用 DNS 进行相同的调用时,它可以很好地工作而不会挂起。

客户端和服务器都是控制台应用程序。服务器运行的是 Windows 7,有问题的客户端运行的是 Windows Server 2008。同一网络上的两台计算机都使用它们的本地安全策略,因此没有域控制器。

关闭所有防火墙和防病毒软件并没有解决我的问题。

这是来自设置的日志,框彼此相邻

09:33:05,252 [1] DEBUG ChannelFactoryManager: Created ClientChannel http://192.168.1.11:18762/DiagnosticService
09:33:05,263 [1] INFO  Program: WcfAppender.InitializeWcfAppender: 08:33:05
09:33:05,274 [1] INFO  Program: File.Copy(C:temptest.txt, O:test.txt, true): 08:33:05
09:33:05,298 [1] INFO  Program: GETTING DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:33:05
09:33:32,661 [1] INFO  Program: GOT DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:33:32
09:33:32,668 [1] INFO  Program: GETTING DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:33:32
09:33:32,680 [1] INFO  Program: GOT DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:33:32
09:33:32,693 [1] INFO  Program: File.Copy(C:temptest.txt, O:test.txt, true): 08:33:32

这是我从不同网络通过互联网访问同一台服务器时的日志(无延迟):

09:36:56,500 [1] DEBUG ChannelFactoryManager: Created ClientChannel http://mydomain.com:18762/DiagnosticService
09:36:56,501 [1] INFO  Program: WcfAppender.InitializeWcfAppender: 08:36:56
09:36:56,501 [1] INFO  Program: File.Copy(C:temptest.txt, O:test.txt, true): 08:36:56
09:36:56,501 [1] INFO  Program: GETTING DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:36:56
09:36:56,680 [1] INFO  Program: GOT DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:36:56
09:36:56,680 [1] INFO  Program: GETTING DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:36:56
09:36:56,705 [1] INFO  Program: GOT DomainFactory.LoggingDiagnosticService.GetMonitoringLevel: 08:36:56

我也尝试在盒子之间复制 test.txt 文件,看看是否遇到同样的连接问题

【问题讨论】:

  • 很久以前我遇到了一个类似的问题。我们通过将代理设置为空来解决它。有时,如果您什么都不设置,连接会尝试使用默认网络代理
  • useDefaultWebProxy="false" 解决了它。多谢。您应该将其作为答案回答,以便我标记它。

标签: c# wcf networking basichttpbinding


【解决方案1】:

定义默认代理时可能会发生这种类型的错误:通过将其添加到您的 app.config 来禁用默认代理

<system.net>
    <defaultProxy enabled="false" useDefaultCredentials="false">
        <proxy />
        <bypasslist />
        <module />
    </defaultProxy>
</system.net>

或者使用你在评论中已经说过的 useDefaultWebProxy="false" :-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-23
    • 2012-07-19
    • 2012-06-12
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-26
    相关资源
    最近更新 更多