Cha*_*adD 9 vb.net web-services asmx
我有一个胖的VB.NET Winform客户端,它使用旧的asmx样式的Web服务.通常,当我执行需要一段时间的查询或将大量数据传递给数据集中的Web服务时,我会遇到主题错误.
该错误似乎发生在<1分钟内,远远小于我设置的Web服务超时值或在Web服务器中执行查询的ADO Command对象上的超时值.
每当我执行一个期望返回大量行的大型查询或者我向Web服务发送大量数据时,似乎就会发生这种情况.例如,它只是在我将大型数据集传递到Web服务器时发生的:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
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)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.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)
--- End of inner exception stack trace ---
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 Smit.Pipeline.Bo.localhost.WsSR.SaveOptions(String emailId, DataSet dsNeighborhood, DataSet dsOption, DataSet dsTaskApplications, DataSet dsCcUsers, DataSet dsDistinctUsers, DataSet dsReferencedApplications) in C:\My\Code\Pipeline2\Smit.Pipeline.Bo\Web References\localhost\Reference.vb:line 944
at Smit.Pipeline.Bo.Options.Save(TaskApplications updatedTaskApplications) in
Run Code Online (Sandbox Code Playgroud)
我一直在寻找关于这个错误的大量帖子,并且令人惊讶的是导致这个错误的情况多种多样.我已经尝试过使用Wireshark,但我对如何使用它毫无头绪.
此应用程序在任何时候只有大约20个用户,我可以在半夜重现此错误,当时可能没有人使用该应用程序,所以我不认为对Web服务器的请求数量或到数据库很高.我可能是现在唯一使用该应用程序的人,我现在才得到错误.它似乎必须做任何事情,在任何一个方向传递数据的amt.
这个错误真的很慢,让我很伤心.请帮忙.
检查客户端的 app.config 绑定设置并查看是否指定了最大消息大小。默认值为 65536
要更改此设置,请将其放入 app.config 中的绑定配置中(maxReceivedMessageSize、maxBufferSize 和 maxArrayLength 是此功能的关键属性),或者以编程方式更改绑定上的属性,如下所示
System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
// if you are getting a LOT of data back, you will need to up Message Size
binding.MaxReceivedMessageSize = int.MaxValue;
Run Code Online (Sandbox Code Playgroud)
如果这不能解决您的问题,您将必须检查服务器端的事件日志以获取详细信息。该消息意味着客户端并不希望连接关闭,但它确实关闭了,并且它可能意味着许多不同的事情。
如果可能,请使用 WCF 进行 Web 服务。它解决了 ASMX 服务仍然遇到的许多问题。
要增加服务器端传输限制和执行超时,请使用此
<configuration>
<system.web>
<httpRuntime maxMessageLength="409600" executionTimeoutInSeconds="300"/>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
90141 次 |
| 最近记录: |