来自网站但不来自控制台应用程序的 Web 服务调用中出现 EndpointNotFoundException
我在网站的 Web 服务调用中收到此 EndpointNotFoundException
,而如果我从控制台应用程序执行此操作,则同样的调用也有效。 这是更详细的异常消息:
Could not connect to https://******. 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 ***.***.***.***:443.
我已经确认绑定(在 web.config
和 app.config
中)是相同的,所以我不明白为什么会这样在一种情况下有效,在另一种情况下无效。
<basicHttpBinding>
<binding name="ServicePortBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
如果您需要更多详细信息,请告诉我。
编辑
好的,这是我遗漏的一些可能导致问题的内容。这一切都发生在公司防火墙后面。 难道说防火墙阻止它从网站运行,因为它是从现有的“Web 进程”产生的 HTTP 连接?而在控制台应用程序中,它只是一个连接。
I'm getting this EndpointNotFoundException
on a webservice call from a website, while the same exact call works if I do it from a console application.
Here's the more detailed exception message:
Could not connect to https://******. 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 ***.***.***.***:443.
I've confirmed that the bindings (in web.config
and app.config
) are the same, so I can't see why it works in one case and not in the other.
<basicHttpBinding>
<binding name="ServicePortBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
Let me know if you need any more details.
EDIT
OK, here's something I left out that might be causing the issue. This is all happening behind the company firewall.
Could it be that said firewall is preventing it from running from the website because it's an HTTP connection spawned from an existing "web process"? Whereas in the console app it's just a single connection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在 web.config 中添加代理旁路
这将允许您通过防火墙打开与服务的连接
You need to add a proxy bypass in your web.config
This will allow you to open a connection to the service through your firewalls
您是否尝试过使用wireshark(如果是HTTP,则使用Fiddler)来查看出站调用是否等效且正确?
Have you tried using wireshark (or Fiddler if it's HTTP) to see if the outbound calls appear to be equivalent and correct?
听起来和闻起来都像是权限问题。
您的 Web 应用程序通常作为 ASPNET 或 NETWORK SERVICE 运行,而您的控制台应用程序将作为您自己(您的帐户)运行。
有没有可能有问题??
您是否在 WCF 服务器端执行任何可能适用于普通用户帐户但不适用于 ASPNET/NETWORK SERVICE 的身份验证?
Sounds and smells like a permission issue.
Your web app typically runs as ASPNET or NETWORK SERVICE, while your console app will run as yourself (your account).
Any chance there's a problem there??
Do you do any kind of authentication on the WCF server end that might work for normal user account, but not for ASPNET / NETWORK SERVICE??