【问题标题】:An error occurred while receiving the HTTP response to <My wcf service deployed at IIS>接收对 <My wcf service deploy at IIS> 的 HTTP 响应时出错
【发布时间】:2011-09-21 00:49:05
【问题描述】:

当我尝试调用与 asp.net 服务器端网页不同的服务器(生产)上的 Web 服务时,它有时会毫无异常地执行,有时我会得到标题中提到的这个异常。我用过wshttpbinding。我还发布了完整的堆栈跟踪。但最后一个内部异常说:

无法从传输中读取数据 连接:现有的连接是 被远程主机强行关闭。

根据我的搜索,某处说它是由于绑定错误,某处其书面 IIS 权限被阻塞,而且超时限制也很小。我增加了超时但没有更改绑定和 IIS 帐户,因为我相信如果这是它甚至不会成功执行一次的问题。这种行为是高度零星的,成功率为 50%。还有一些用户报告了这个问题,在正常的 asp.net 调用中也没有涉及 wcf。

此 Web 服务调用不带任何参数,也不返回任何数据。 (FireAndForget 之类的场景)。

异常信息:

接收时发生错误 HTTP 响应 https://json.clickable.com/BMS/NetSuiteCommunicationService.svc。 这可能是由于服务 不使用 HTTP 的端点绑定 协议。这也可能是由于 HTTP 请求上下文被中止 服务器(可能是由于 服务关闭)。见服务器 日志以获取更多详细信息。

堆栈跟踪:

服务器堆栈跟踪:在 System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException,HttpWebRequest 请求, HttpAbortReason abortReason) 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)在 System.ServiceModel.Channels.RequestChannel.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Channels.ClientReliableChannelBinder1.RequestClientReliableChannelBinder1.OnRequest(TRequestChannel 频道,消息消息,时间跨度 超时,MakingMode maskingMode)在 System.ServiceModel.Channels.ClientReliableChannelBinder1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) at System.ServiceModel.Channels.ClientReliableChannelBinder1.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息 消息,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串 动作,单向布尔值, ProxyOperationRuntime 操作, Object[] 输入,Object[] 输出,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 方法调用、代理操作运行时 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 Clickable.Scheduler.BLL.NetsuiteService.INetSuiteCommunicationService.ExecuteAddAdNetworkToCustomerTask() 在 Clickable.Scheduler.BLL.Configuration.Tasks.AdNetworkToCustomerTask.Run() 在 Clickable.Scheduler.BLL.Configuration.Tasks.Task.Excecute()

异常消息:底层 连接已关闭:意外 接收时出错。

堆栈跟踪:在 System.Net.HttpWebRequest.GetResponse() 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度 超时)

异常消息:无法读取数据 从传输连接:一个 现有连接被强制 被远程主机关闭。

堆栈跟踪:在 System.Net.Sockets.NetworkStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小)在 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(字节 [] 缓冲区,Int32 偏移量,Int32 大小)在 System.Net.PooledStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小)在 System.Net.Connection.SyncRead(HttpWebRequest 请求,布尔用户检索流, Boolean probeRead)

异常消息:现有 连接被强行关闭 远程主机

堆栈跟踪:在 System.Net.Sockets.NetworkStream.Read(字节 [] 缓冲区,Int32 偏移量,Int32 大小)

【问题讨论】:

  • 所有故事都很难阅读,请格式化您的问题。
  • 你能打开跟踪看看服务端发生了什么吗?这是一个屏幕截图,向您展示rocksolidknowledge.com/ScreenCasts.mvc/…
  • 你后来找到解决这个问题的方法了吗?

标签: asp.net wcf web-services


【解决方案1】:

我知道这很旧,但对于发现这个的人来说:我有同样的异常。我通过在 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;

【讨论】:

    猜你喜欢
    • 2013-03-27
    • 2013-02-26
    • 2023-01-30
    • 1970-01-01
    • 2014-06-03
    • 2018-03-22
    • 2023-03-29
    • 1970-01-01
    相关资源
    最近更新 更多