c# - 通过 Azure 服务总线读取从 WCF 服务返回的流时出现 IOException 和 SocketException

标签 c# wcf azure large-files servicebus

我们创建了一个下载应用程序,该应用程序从驻留在远程计算机上的 WCF 服务主机下载大型 zip 文件(>200 MB)。客户端使用“nettcprelaybinding”通过azure服务总线与此WCF服务进行通信。

为了下载 zip 文件,WCF 服务创建一个流并将其返回。在客户端,我们使用此流写入 zip 文件。

但是在阅读这个流的过程中,我随机得到IOException,上面写着 “读取流时抛出异常。”。 当我仔细观察内部异常时,我发现 SocketException (s) 排成一排。

以下是客户端 WCF 跟踪实用程序的 XML 堆栈跟踪:

<Exception>
<ExceptionType>System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>An exception has been thrown when reading the stream.</Message>
<StackTrace>
at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at RPKDDM.ViewModel.SearchQueueViewModel.DownloadBackground(Object sender, DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]&amp; outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
</StackTrace>
<ExceptionString>System.IO.IOException: An exception has been thrown when reading the stream. ---&gt; System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'. ---&gt; System.IO.IOException: The read operation failed, see inner exception. ---&gt; System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'. ---&gt; 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 Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   at Microsoft.ServiceBus.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   --- End of inner exception stack trace ---
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.ServiceBus.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.HybridConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   at Microsoft.ServiceBus.Channels.HybridConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.SingletonConnectionReader.SingletonInputConnectionStream.ReadCore(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.ServiceBus.Channels.SingletonConnectionReader.SingletonInputConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.ServiceBus.Channels.MaxMessageSizeStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Xml.XmlBufferReader.TryEnsureBytes(Int32 count)
   at System.Xml.XmlBufferReader.EnsureBytes(Int32 count)
   at System.Xml.XmlBufferReader.ReadBytes(Int32 count)
   at System.Xml.XmlBinaryReader.ReadText(XmlTextNode textNode, ValueHandleType type, Int32 length)
   at System.Xml.XmlBinaryReader.ReadPartialBinaryText(Boolean withEndElement, Int32 length)
   at System.Xml.XmlBinaryReader.ReadNode()
   at System.Xml.XmlBinaryReader.Read()
   at System.Xml.XmlBaseReader.MoveToContent()
   at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   --- End of inner exception stack trace ---</ExceptionString>
<InnerException>
<ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'.</Message>
<StackTrace>
at Microsoft.ServiceBus.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at Microsoft.ServiceBus.Channels.HybridConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
at Microsoft.ServiceBus.Channels.HybridConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at Microsoft.ServiceBus.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at Microsoft.ServiceBus.Channels.SingletonConnectionReader.SingletonInputConnectionStream.ReadCore(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.ServiceBus.Channels.SingletonConnectionReader.SingletonInputConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.ServiceBus.Channels.MaxMessageSizeStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Xml.XmlBufferReader.TryEnsureBytes(Int32 count)
at System.Xml.XmlBufferReader.EnsureBytes(Int32 count)
at System.Xml.XmlBufferReader.ReadBytes(Int32 count)
at System.Xml.XmlBinaryReader.ReadText(XmlTextNode textNode, ValueHandleType type, Int32 length)
at System.Xml.XmlBinaryReader.ReadPartialBinaryText(Boolean withEndElement, Int32 length)
at System.Xml.XmlBinaryReader.ReadNode()
at System.Xml.XmlBinaryReader.Read()
at System.Xml.XmlBaseReader.MoveToContent()
at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.Read(Byte[] buffer, Int32 offset, Int32 count)
</StackTrace>
<ExceptionString>System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'. ---&gt; System.IO.IOException: The read operation failed, see inner exception. ---&gt; System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'. ---&gt; 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 Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   at Microsoft.ServiceBus.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   --- End of inner exception stack trace ---
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.ServiceBus.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.HybridConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   at Microsoft.ServiceBus.Channels.HybridConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.SingletonConnectionReader.SingletonInputConnectionStream.ReadCore(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.ServiceBus.Channels.SingletonConnectionReader.SingletonInputConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.ServiceBus.Channels.MaxMessageSizeStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Xml.XmlBufferReader.TryEnsureBytes(Int32 count)
   at System.Xml.XmlBufferReader.EnsureBytes(Int32 count)
   at System.Xml.XmlBufferReader.ReadBytes(Int32 count)
   at System.Xml.XmlBinaryReader.ReadText(XmlTextNode textNode, ValueHandleType type, Int32 length)
   at System.Xml.XmlBinaryReader.ReadPartialBinaryText(Boolean withEndElement, Int32 length)
   at System.Xml.XmlBinaryReader.ReadNode()
   at System.Xml.XmlBinaryReader.Read()
   at System.Xml.XmlBaseReader.MoveToContent()
   at System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.Read(Byte[] buffer, Int32 offset, Int32 count)</ExceptionString>
<DataItems>
<Data>
<Key>Microsoft.ServiceBus</Key>
<Value>Microsoft.ServiceBus</Value>
</Data>
</DataItems>
<InnerException>
<ExceptionType>System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The read operation failed, see inner exception.</Message>
<StackTrace>
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at Microsoft.ServiceBus.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
</StackTrace>
<ExceptionString>System.IO.IOException: The read operation failed, see inner exception. ---&gt; System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'. ---&gt; 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 Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   at Microsoft.ServiceBus.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   --- End of inner exception stack trace ---
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.ServiceBus.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)</ExceptionString>
<InnerException>
<ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'.</Message>
<StackTrace>
at Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
at Microsoft.ServiceBus.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at Microsoft.ServiceBus.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
</StackTrace>
<ExceptionString>System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '22:59:58.0620000'. ---&gt; 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 Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   --- End of inner exception stack trace ---
   at Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
   at Microsoft.ServiceBus.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
   at Microsoft.ServiceBus.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)</ExceptionString>
<DataItems>
<Data>
<Key>Microsoft.ServiceBus</Key>
<Value>Microsoft.ServiceBus</Value>
</Data>
</DataItems>
<InnerException>
<ExceptionType>System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>An existing connection was forcibly closed by the remote host</Message>
<StackTrace>
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
</StackTrace>
<ExceptionString>System.Net.Sockets.SocketException (0x80004005): 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 Microsoft.ServiceBus.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)</ExceptionString>
<NativeErrorCode>2746</NativeErrorCode>
</InnerException>
</InnerException>
</InnerException>
</InnerException>
</Exception>

流媒体契约(Contract)

[MessageContract]

public class StreamFileInfo : IDisposable
{
    [MessageHeader(MustUnderstand = true)]
    public string FileName;

    [MessageHeader(MustUnderstand = true)]
    public long Length;

    [MessageHeader(MustUnderstand = true)]
    public bool IsEmpty;

    [MessageHeader(MustUnderstand = true)]
    public string QueueNumber;

    [MessageBodyMember(Order = 1)]
    public Stream FileByteStream;

    public void Dispose()
    {
        if (FileByteStream != null)
        {
            FileByteStream.Close();
            FileByteStream.Dispose();
            FileByteStream = null;
        }
    }
}

读取流的代码:

    int bufferSize = 4096;
    byte[] buffer = new byte[bufferSize];

    int bytesRead = streamInfo.FileByteStream.Read(buffer, 0, buffer.Length);
    int totalBytesRead += bytesRead;

    while (bytesRead > 0)
{
//WRITE BUFFER TO ZIP FILE
zipFileStream.Write(buffer, 0, bytesRead);
zipFileStream.Flush();
buffer = new byte[bufferSize];

//READ BYTES FROM SERVER STREAM
bytesRead = streamInfo.FileByteStream.Read(buffer, 0, buffer.Length);
totalBytesRead += bytesRead;

}

读取过程完成后,我将在finally block 中处理该流。

客户端绑定(bind):

<netTcpRelayBinding>
        <binding name="default"
                 connectionMode="Hybrid"
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="0"          
                 transferMode="Streamed"
                 closeTimeout="01:00:00"
                 openTimeout="00:30:00"
                 sendTimeout="05:00:00"
                 receiveTimeout="05:00:00"
                 maxConnections="2500"
                 listenBacklog="200">


          <security mode="None"/>
          <readerQuotas maxBytesPerRead="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" />
          <reliableSession enabled="false" ordered="true" inactivityTimeout="00:30:00"/>
        </binding>
      </netTcpRelayBinding>

服务器上存在类似的绑定(bind) 在服务中,我还启用了设置最大值的节流。

服务行为配置:

<services>
      <!-- Application Service -->
      <service name="DDMService.DDMBaseService" behaviorConfiguration="ThrottleBehavior">
        <endpoint name="RelayEndpoint"
                  contract="IBaseService"
                  binding="netTcpRelayBinding"
                  bindingConfiguration="default"
                  behaviorConfiguration="asyncBehavior"
                  address=""/>        
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ThrottleBehavior">
          <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentInstances="2147483647" maxConcurrentSessions="2147483647"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="asyncBehavior">
          <dispatcherSynchronization asynchronousSendEnabled="true"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

我完全不知道为什么会发生这种情况。 是否由于某些服务总线错误或已知问题或服务总线超时? 对于服务总线配额,我引用此链接: http://msdn.microsoft.com/library/ee732538.aspx

我在这里做错了什么?我是否需要设置适当的缓冲区大小来读取流?或者我需要设置 maxBufferSizemaxBufferPoolSize

我已经尝试将 maxBufferSizemaxBufferPoolSize 设置为 2147483647。 但这没有帮助。

对于大文件流,我引用此链接: http://msdn.microsoft.com/en-us/library/ms733742.aspx

我真的受够了,无法理解为什么会出现这个错误。 请帮忙。

编辑: 如果无法帮助我解决上述问题,请告诉我如何在发生 IOException 时从同一点恢复流式传输?这会有很大的帮助。非常感谢。

最佳答案

您知道可以从 Azure Blob 存储获得出色的文件流功能,对吗?

如果文件已经是 zip 文件,我会研究一下,因为它将使您或多或少地删除 WCF 层。

如果没有,请尝试查看此 WCF Streaming large data (500MB / 1GB) on a self hosted service

关于c# - 通过 Azure 服务总线读取从 WCF 服务返回的流时出现 IOException 和 SocketException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18870857/

相关文章:

c# - 单元测试项目 Azure Functions 无法加载文件或程序集 'Newtonsoft.Json'

c# - HTML 5 数据列表选项

php - 如何创建用于在 SSL 下调用 WCF Web 服务的 PHP SOAP 客户端?

c# - 为 WCF 服务启用 HTTPS 流量。将流量 http 更改为 https 的问题

Azure AD B2C - 更改注册/登录策略中的应用程序

Azure CosmosDB REST API 忽略数据浏览器返回的结果

c# - 如何从 C# 中的字符串中提取 href 标签?

c# - ComboBox 元素的样式

WCF REST 服务端点未找到 WebInvoke 错误

node.js - Azure - 每个 Web 应用程序进行多个部署?