gpt4 book ai didi

c# - 无法连接到远程 WCF 服务 - TimeoutException

转载 作者:行者123 更新时间:2023-11-30 17:08:13 25 4
gpt4 key购买 nike

我之前问过一个 question在尝试从远程计算机访问 WCF 服务时解决 SecurityNegotiationException。由于 ValtasarIII 的回答,该异常已得到解决。

现在我有一个不同的问题。我在服务器上托管了我的服务,并希望使用客户端应用程序连接到它。但是,当我尝试从客户端应用程序订阅服务时,没有任何反应,最后我得到了异常:

The open operation did not complete within the allotted timeout of 00:00:59.9939996. The time allotted to this operation may have been a portion of a longer timeout.

(如有必要,我可以分享堆栈跟踪)

尽管当我尝试测试该服务是否正在运行时,我可以从客户端计算机通过浏览器成功访问它。

这是我的配置:

服务 - web.config

<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="wsHttpDual">
<security mode="None">
<message clientCredentialType="None" algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<protocolMapping>
<add scheme="http" binding="wsDualHttpBinding" bindingConfiguration="wsHttpDual"/>
</protocolMapping>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

客户端 - app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ISampleContract" clientBaseAddress="http://95.138.188.232:8000/myClient/">
<!--<security mode="Message">
<message clientCredentialType="Windows" algorithmSuite="Default" />
</security>-->
<security mode="None">
<message clientCredentialType="None" algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://95.138.188.232/autofxtools/service.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ISampleContract"
contract="ISampleContract" name="WSDualHttpBinding_ISampleContract">
<identity>
<servicePrincipalName value="host/95.138.188.232" />
</identity>
</endpoint>

</client>
</system.serviceModel>
</configuration>

我一直在寻找解决方案,但没有任何效果。服务配置似乎没有安全要求。但是,具有相同配置的客户端实际上与服务在同一台机器上工作,而不是在远程机器上工作。这是否意味着仍然存在 Windows 身份验证(根据 wsDualHttpBinding 的默认设置)?如果是这样,那我哪里出错了?

希望得到一些积极的反馈。

问候。

最佳答案

这可能是防火墙问题。我假设您在 ISS 内托管该服务 - 您确定相应的端口已打开吗?当您尝试通过浏览器访问该服务时会发生什么?

此外,我在德国论坛上读到以下内容:

Anscheinend tritt das Problem nur bei WsDualBinding auf, wenn der Port 80 belegt ist. Gibt wohl keine Möglichkeit den Port mit Hilfe von ClientBaseAdress zu ändern. Einzige Möglichkeit ist hier wohl netTcpBinding.

在英文中是指:

Obviously this problem arises when using WsDualBinding while port 80 is already occupied. There seems to be no way to change the port using ClientBaseAddress. The only way seems to be to use netTcpBinding.

关于c# - 无法连接到远程 WCF 服务 - TimeoutException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13948026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com