当我尝试传输超过150MB的文件时,我遇到了以下错误。
System.ServiceModel.CommunicationException was unhandled
Message="An error occurred while making the HTTP request to http://localhost:2122/Service1.svc. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server."
Source="mscorlib"
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Cleint.ServiceReference1.IService1.UploadFile(RemoteFileInfo request)
at Cleint.ServiceReference1.Service1Client.Cleint.ServiceReference1.IService1.UploadFile(RemoteFileInfo request) in D:\MCT_Work\Sample Projects\WCFFileTransferTest\Cleint\Service References\ServiceReference1\Reference.cs:line 81
at Cleint.ServiceReference1.Service1Client.UploadFile(String fileName, Stream fileByteStream) in D:\MCT_Work\Sample Projects\WCFFileTransferTest\Cleint\Service References\ServiceReference1\Reference.cs:line 88
at Cleint.Program.Main(String[] args) in D:\MCT_Work\Sample Projects\WCFFileTransferTest\Cleint\Program.cs:line 20
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Net.WebException
Message="The underlying connection was closed: An unexpected error occurred on a send."
Source="System"
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
InnerException: System.IO.IOException
Message="Unable to write data to the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full."
Source="System"
StackTrace:
at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
at System.Net.Connection.Write(ScatterGatherBuffers writeBuffer)
at System.Net.ConnectStream.ResubmitWrite(ConnectStream oldStream, Boolean suppressWrite)
InnerException: System.Net.Sockets.SocketException
Message="An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full"
Source="System"
ErrorCode=10055
NativeErrorCode=10055
StackTrace:
at System.Net.Sockets.Socket.MultipleSend(BufferOffsetSize[] buffers, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
InnerException:
答案 0 :(得分:1)
默认情况下,transferMode
为缓冲区,因此大型邮件会在内存中缓冲。如果您可以访问更改服务目标(代码),我建议您使用传输模式流式传输或 MTOM 邮件编码来交换此类大型邮件/文件。
答案 1 :(得分:0)
为什么要尝试在Web服务边界上传输150MB?此设计几乎肯定会导致服务端点上的可用性问题。
更好的设计是将文件写入某处的磁盘,然后向服务发送命令消息以获取文件。