ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Linq AsParallel()是否可以过早地处理SoapHttpClientProtocol对象?

2019-11-21 06:07:51  阅读:261  来源: 互联网

标签:asp-net-mvc-4 soap-client plinq arcgis-server c


在我正在使用的ASP.Net MVC 4 Web应用程序中.我有一页基本上通过从SOAP服务获取数据来生成报告.

我的代码基本上是这样的

List<CustomThings> serverInfos = ServerInfos;
serverInfos.AsParallel().ForAll(srvInfo =>
{
    SoapHttpClientProtocol soapProxy = CreateProxy(srvInfo);
    //call make soap calls through the soap client
    //store results in the proper places
}

我在这里做AsParallel的原因是因为以串行方式通过HTTP进行多个请求会花费很多时间.尽管偶尔会出现,但我还是认为该代码确实有效.

事情是否有可能以不可预测的方式处理,而PLINQ并不是我在这里尝试做的一个好的解决方案?

是否可能另一个线程问题可能导致使soap客户端“放弃”的错误?

附加信息

该特定的肥皂代理正在与ArcGIS Server通信.通常,您可以检查服务器日志并查看何时启动特定请求以及请求是否失败.这些日志中没有任何显示.

这是我从AsParallel代码获得的内部异常堆栈跟踪的示例.

Exception: System.AggregateException: One or more errors occurred.
—> System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the
server. —> 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
ESRI.ArcGIS.SOAP.FeatureServerProxy.Query(Int32 LayerOrTableID, String
DefinitionExpression, QueryFilter QueryFilter, ServiceDataOptions
ServiceDataOptions, String GdbVersion, Double MaximumAllowableOffset)
at
System.Linq.Parallel.SelectQueryOperator2.SelectQueryOperatorResults.GetElement(Int32
index) at System.Linq.Parallel.QueryResults
1.get_Item(Int32 index)
at
System.Linq.Parallel.PartitionedDataSource1.ListContiguousIndexRangeEnumerator.MoveNext(T&
currentElement, Int32& currentKey) at
System.Linq.Parallel.PipelineSpoolingTask
2.SpoolingWork() at
System.Linq.Parallel.SpoolingTaskBase.Work() at
System.Linq.Parallel.QueryTask.BaseWork(Object unused) at
System.Linq.Parallel.QueryTask.<.cctor>b__0(Object o) at
System.Threading.Tasks.Task.InnerInvoke() at
System.Threading.Tasks.Task.Execute()

解决方法:

PLINQ甚至不知道您的连接对象存在.它无法关闭它.

仔细阅读消息:

An existing connection was forcibly closed by the remote host.

服务器以意外方式关闭了连接.您的客户没有错.

准确地解释异常是必不可少的调试技能.该信息就在异常消息中.

也许您产生了太多的负载.设置可持续的并行度.默认启发式方法用于CPU工作,而不用于IO.

.WithDegreeOfParallelism(10)

A connection that was expected to be kept alive was closed by the server.

这可能意味着服务器不支持HTTP保持活动状态.

标签:asp-net-mvc-4,soap-client,plinq,arcgis-server,c
来源: https://codeday.me/bug/20191121/2049756.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有