当我尝试从asp.net服务器端网页调用位于不同服务器(生产)上的我的Web服务时,它会在没有任何异常的情况下执行,有时我会在标题中提到此异常。我用过wshttpbinding。我也发布了完整的堆栈跟踪。但最后一个内部异常说:
无法从传输中读取数据 连接:现有连接是 被远程主机强行关闭。
根据我的搜索,它在某处说它是由于错误的绑定,某处其写入的IIS权限被阻止,并且还有很小的超时限制。我已经增加了时间,但没有更改绑定和IIS帐户,因为我相信这是一个问题,即使一次也不会成功执行。这种行为是非常零星的,成功率为50%。而且一些用户也报告了这个问题,正常的asp.net调用也没有涉及wcf。
此Web服务调用不接受任何参数,也不返回任何数据。 (FireAndForget种类的场景)。
异常消息:
接收时发生错误 HTTP响应 https://json.clickable.com/BMS/NetSuiteCommunicationService.svc。 这可能是由于服务 端点绑定不使用HTTP 协议。这也可能是由于 HTTP请求上下文被中止 服务器(可能是由于 服务关闭)。见服务器 记录更多详细信息。
堆栈追踪:
服务器堆栈跟踪:at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(引发WebException webException,HttpWebRequest请求, HttpAbortReason abortReason)at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)at System.ServiceModel.Channels.RequestChannel.Request(消息 消息,TimeSpan超时)at System.ServiceModel.Channels.ClientReliableChannelBinder
1.RequestClientReliableChannelBinder
1.OnRequest(TRequestChannel 频道,消息消息,TimeSpan 超时,MaskingMode maskingMode)at System.ServiceModel.Channels.ClientReliableChannelBinder1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) at System.ServiceModel.Channels.ClientReliableChannelBinder
1.Request(消息 消息,TimeSpan超时)at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(消息 消息,TimeSpan超时)at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息 消息,TimeSpan超时)at System.ServiceModel.Channels.ServiceChannel.Call(字符串 动作,布尔单向, ProxyOperationRuntime操作, Object [] ins,Object [] outs,TimeSpan 超时)at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作) System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天 消息)在[0]处重新抛出异常:at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(即时聊天 reqMsg,IMessage retMsg)at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&安培; msgData,Int32类型)at Clickable.Scheduler.BLL.NetsuiteService.INetSuiteCommunicationService.ExecuteAddAdNetworkToCustomerTask() 在 Clickable.Scheduler.BLL.Configuration.Tasks.AdNetworkToCustomerTask.Run() 在 Clickable.Scheduler.BLL.Configuration.Tasks.Task.Excecute()
异常消息:底层消息 连接已关闭:意外 收到错误。
Stack Trace:at System.Net.HttpWebRequest.GetResponse() 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)
异常消息:无法读取数据 从运输连接:An 现有的联系是强行的 由远程主机关闭。
Stack Trace:at System.Net.Sockets.NetworkStream.Read(字节[] 缓冲区,Int32偏移量,Int32大小)at System.Net.FixedSizeReader.ReadPacket(字节[] 缓冲区,Int32偏移量,Int32计数)
在 System.Net.Security._SslStream.StartFrameHeader(字节[] 缓冲区,Int32偏移量,Int32计数, AsyncProtocolRequest asyncRequest)
在 System.Net.Security._SslStream.StartReading(字节[] 缓冲区,Int32偏移量,Int32计数, AsyncProtocolRequest asyncRequest)
在 System.Net.Security._SslStream.ProcessRead(字节[] 缓冲区,Int32偏移量,Int32计数, AsyncProtocolRequest asyncRequest)
在System.Net.TlsStream.Read(Byte [] 缓冲区,Int32偏移量,Int32大小)at System.Net.PooledStream.Read(字节[] 缓冲区,Int32偏移量,Int32大小)at System.Net.Connection.SyncRead(HttpWebRequest的 request,Boolean userRetrievedStream, Boolean probeRead)异常消息:现有消息 连接被强制关闭 远程主机
Stack Trace:at System.Net.Sockets.NetworkStream.Read(字节[] buffer,Int32 offset,Int32 size)
答案 0 :(得分:0)
我知道这很旧,但是对于发现它的人来说:我也有同样的Exception。我通过在web.config中定义跟踪来找出错误。
<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Information, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add initializeData="C:/temp/tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="traceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
</system.diagnostics>
我在本地运行网站,触发了一些失败的调用,并打开了跟踪日志,选择失败的条目,在该条目中我看到了以下异常: 不能在LINQ to Entities查询中构造实体或复杂类型“ Person”。 在查询之外构造人可以解决此问题,而不是:
var persons = (from p in db.Persons
select new Person
{
Id = p.Id,
Name = p.Name,
LastName = p.LastName,
Email = p.Email
}
).AsEnumerable();
return persons;
我必须做:
var persons = (from p in db.Persons
select new
{
Id = p.Id,
Name = p.Name,
LastName = p.LastName,
Email = p.Email
}
).AsEnumerable()
//construct the complex type outside of DB (to prevent the exception that model cannot be constructed in linq to entities)
.Select(item =>
new Person
{
Id = item.Id,
Name = item.Name,
LastName = item.LastName,
Email = item.Email
}).ToList();
return persons;