Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET web应用程序无法连接到作为windows服务承载的WCF_Wcf - Fatal编程技术网

ASP.NET web应用程序无法连接到作为windows服务承载的WCF

ASP.NET web应用程序无法连接到作为windows服务承载的WCF,wcf,Wcf,我们有一个WCF服务作为windows服务托管,在应用服务器上有tcp绑定。我们有一个ASP.NET web应用程序托管在一个单独的web服务器上,该服务器正在尝试连接到它。两台服务器都是Windows 2008 R2计算机 ASP.NET web应用程序的应用程序池设置为使用ApplicationPoolIdentity作为其用户。当我们尝试从windows计算机连接到WCF服务时,出现以下错误: Source Exception: System.Web.HttpUnhandledExcept

我们有一个WCF服务作为windows服务托管,在应用服务器上有tcp绑定。我们有一个ASP.NET web应用程序托管在一个单独的web服务器上,该服务器正在尝试连接到它。两台服务器都是Windows 2008 R2计算机

ASP.NET web应用程序的应用程序池设置为使用ApplicationPoolIdentity作为其用户。当我们尝试从windows计算机连接到WCF服务时,出现以下错误:

Source Exception: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:09.9980000'. ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:09.9980000'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
但是,当我们将应用程序池的用户切换到网络服务时,它会连接无误


我的问题有两个方面。有人知道为什么使用ApplicationPoolIdentity不起作用吗?这是某种配置问题吗?而且,在网络服务帐户下运行应用程序池的缺点是什么?我知道ApplicationPoolIdentity的权限更少,更安全,被认为是最佳实践

答案取决于网络、服务器和服务中的不同配置

我在过去也遇到过类似的情况,ApplicationPoolIdentity无权与机器之外的资源“对话”


另一个问题可能是如何处理web应用程序和服务器之间的连接。您是每次都重复使用相同的连接,还是关闭/重新打开频道?有一些关于这方面的信息

这是一个很好的观点,ASP.NET web应用程序每次打开和关闭与WCF服务的连接。这个特殊的特性没有得到足够的利用来证明维护持久连接的合理性。ApplicationPoolIdentity似乎没有与外部资源对话的权限,就像您的情况一样。你能解决这个问题吗?在我的例子中,是域策略阻止了这一点,所以我们转而将应用程序池作为专用域帐户运行。不确定您的环境是什么样子的,但请检查防火墙配置。我们必须检查一下。谢谢您的帮助。@bwalk2895您是否知道该设置是在哪里配置的?