我有一个ASP.NET (VB.NET) Web 应用程序(针对 .NET 4 Framework),它在尝试通过 Web 引用调用 Web 方法时间歇性地抛出异常。Web 参考是带有.asmx文件扩展名的老式ASP.NET Web 服务。
主 Web 应用程序和 Web 服务都在IIS 7.5 / Windows 2008 SP1上。在 IIS 中,两个应用程序都在同一个网站上,但在不同的应用程序池中。
异常状态为“远程主机强制关闭现有连接”。这个错误很奇怪,因为它不会在调用 web 方法的前几次抛出异常。但是当错误被抛出时,它将继续在每个后续实例上抛出。在 IIS 中重新启动应用程序池可修复该错误。
传输的数据很少,所以我认为它与数据的大小无关。
最近我们安装了一个 F5 设备作为反向代理。Web 服务现在在此设备后面运行。我们这样做是为了将应用程序移至DMZ(非军事区)。这可能是导致此问题的原因,但如果是我不确定如何正确配置它。
这是我的代码:
_webService = New BWebService.BWebService()
_webService.Url = EnvironmentSettingsLocator.Settings.BWebServiceWsdl
If Not _webService.IsExistingUser(userId) Then
' Do Something
end if
这是一个例外:
底层连接已关闭:接收时发生意外错误。
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Apex3Web.BIRVWebService.BIRVWebService.IsExistingUser(Int32 userCode) in C:\Users\Ryan.DeFour.ctr\Documents\Work\TFS Source Code 2010\APEX4CMMI\APEXDevelopment\Apex3Web\Apex3Web\Web References\BIRVWebService\Reference.vb:line 501
at Apex3Web.ManageExaminee.GridViewExaminees_RowDataBound(Object sender, GridViewRowEventArgs e) in C:\Users\Ryan.DeFour.ctr\Documents\Work\TFS Source Code 2010\APEX4CMMI\APEXDevelopment\Apex3Web\Apex3Web\Forms\Examiner\ManageExaminee.aspx.vb:line 651
at System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e)
at System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource)
at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data)
at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
at System.Web.UI.WebControls.GridView.DataBind()
at Apex3Web.ManageExaminee.FindCommand_Click(Object sender, EventArgs e) in C:\Users\Ryan.DeFour.ctr\Documents\Work\TFS Source Code 2010\APEX4CMMI\APEXDevelopment\Apex3Web\Apex3Web\Forms\Examiner\ManageExaminee.aspx.vb:line 539
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
无法从传输连接读取数据:现有连接被远程主机强行关闭。
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
现有连接被远程主机强行关闭
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)