本地网络上的 WCF 初始化挂起 20 秒



我有使用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 文件,以查看我是否遇到相同的连接问题

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

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

或使用 useDefaultWebProxy="false" :-)正如您在评论中已经说过的

最新更新