简体   繁体   English

是什么原因导致.NET Remoting中的“ Tcp通道协议违反预期的前导”?

[英]What causes “Tcp channel protocol violation expecting preamble” in .NET Remoting?

I have a distributed application that uses .NET Remoting on an in-house gigabit network. 我有一个分布式应用程序,它在内部千兆位网络上使用.NET Remoting。 There is a single server, and over a dozen clients that connect to the server. 一台服务器,并且有十几个客户端连接到该服务器。 The clients run multiple threads, and there can be up to 10 concurrent requests from each client. 客户端运行多个线程,每个客户端最多可以有10个并发请求。

This application works very well most of the time. 该应用程序大多数时候都运行良好。 The server stays up for months at a time. 服务器一次可以保持几个月的运行时间。 From time to time I get an exception on a client, and I can't figure out what's causing the exception. 我有时会在客户端上遇到异常,而我无法弄清是什么导致了异常。 The exception and stack trace are: 异常和堆栈跟踪为:

System.Runtime.Remoting.RemotingException: Tcp channel protocol violation: expecting preamble.

Server stack trace: 
   at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadAndMatchPreamble()
   at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16& operation)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

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)

That's the stack trace back to where I make the remoting call. 那是堆栈跟踪,可以追溯到我进行远程调用的地方。

I've looked and can find nothing out of the ordinary in the calls I'm making, or in the data that the server is returning. 我看过了,在我正在进行的调用或服务器返回的数据中找不到任何异常。

Google searches for this error are not very fruitful. Google搜索此错误的结果不是很好。 Most of the errors I've seen revolve around somebody converting from HTTP to TCP and not changing everything, so they get the exception when they try to connect. 我见过的大多数错误都与某人从HTTP转换为TCP而没有更改所有错误有关,因此当他们尝试连接时会遇到异常。 In my case, the client will run for days before I get this error. 就我而言,客户端将运行几天,直到出现此错误。

One other data point: the server does get a lot of requests. 另一个数据点:服务器确实收到了很多请求。 Most of the clients are Web crawlers that each make more than 2,000 requests to the server every minute. 大多数客户端是Web爬网程序,每个爬网程序每分钟向服务器发出2,000多个请求。 So the server is processing upwards of 500 requests per second, with bursts of higher traffic. 因此,服务器每秒处理多达500个请求,并产生大量流量。 In any case, the server seems to handle the traffic okay, and I would expect a much different error if the server became overloaded. 无论如何,服务器似乎都可以正常处理流量,并且如果服务器过载,我会期望一个完全不同的错误。

Any ideas what's causing this error? 任何想法是什么导致此错误?

This error usually happens when a message received with wrong headers. 当收到的邮件标题错误时,通常会发生此错误。 You can repeat this error with creating a telnet connection to your server and type something. 您可以通过与服务器建立telnet连接并键入一些内容来重复此错误。 In most cases it's a network error. 在大多数情况下,这是网络错误。

I highly recommend the check your firewall. 我强烈建议您检查防火墙。 Some firewalls drops the network packets due wrong attack alert. 某些防火墙会由于错误的攻击警报而丢弃网络数据包。

Load balancing is another possible reason. 负载平衡是另一个可能的原因。 Load balancer splits packets to different servers. 负载平衡器将数据包拆分到不同的服务器。

I've see this issue when MS DNS server used too lot of open port, so outbound port can't be created. 当MS DNS服务器使用过多的开放端口时,我已经看到了此问题,因此无法创建出站端口。 Yes, it's very funny. 是的,这很有趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM