Linq AsParallel()是否可以过早地处理SoapHttpClientProtocol对象?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linq AsParallel()是否可以过早地处理SoapHttpClientProtocol对象?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3324字,纯文字阅读大概需要5分钟。
内容图文
![Linq AsParallel()是否可以过早地处理SoapHttpClientProtocol对象?](/upload/InfoBanner/zyjiaocheng/661/6e935347449f4b0cb4a5cb3a382e3708.jpg)
在我正在使用的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
1.get_Item(Int32 index)
index) at System.Linq.Parallel.QueryResults
at
System.Linq.Parallel.PartitionedDataSource1.ListContiguousIndexRangeEnumerator.MoveNext(T&
2.SpoolingWork() at
currentElement, Int32& currentKey) at
System.Linq.Parallel.PipelineSpoolingTask
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保持活动状态.
内容总结
以上是互联网集市为您收集整理的Linq AsParallel()是否可以过早地处理SoapHttpClientProtocol对象?全部内容,希望文章能够帮你解决Linq AsParallel()是否可以过早地处理SoapHttpClientProtocol对象?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。