java SocketException (0x80004005): 现有连接被远程主机强行关闭

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17193194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 01:16:31  来源:igfitidea点击:

SocketException (0x80004005): An existing connection was forcibly closed by the remote host

c#javatcpshared-memory

提问by user1584120

Hoping somebody can help with this exception. Our client app can spawn up to 3 server apps (new processes) and communicates with each through TCP. These in turn spawn a jvm when prompted (server app essentially a wrapper for communicating to jvm through shared memory). When I set the memory on each jvm to be about 25gb (I have 8gb ram) it will not run any of the 3 server applications and throws the above exception. When I set it be 10gb it will run one of them but throw that exception when I try start the second jvm. The exception appears to happen when I try and start the jvm (prints logging statement just before it makes first java call) however this exception is only captured on the client side. I'm wondering if this is a stackoverflow on the server side?

希望有人可以帮助解决这个例外。我们的客户端应用程序最多可以生成 3 个服务器应用程序(新进程)并通过 TCP 与每个应用程序通信。这些反过来会在提示时生成一个 jvm(服务器应用程序本质上是一个用于通过共享内存与 jvm 通信的包装器)。当我将每个 jvm 上的内存设置为大约 25gb(我有 8gb ram)时,它不会运行 3 个服务器应用程序中的任何一个并抛出上述异常。当我将它设置为 10gb 时,它将运行其中一个,但在我尝试启动第二个 jvm 时抛出该异常。当我尝试启动 jvm 时似乎发生了异常(在它进行第一次 java 调用之前打印日志语句)但是这个异常只在客户端被捕获。我想知道这是否是服务器端的stackoverflow?

12:58:33 : Exception : System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
Server stack trace: 
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Runtime.Remoting.Channels.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[] buffer)
at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16& operation)
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)
at Isl.RemotableObjects.ServerMgmtIF.initialiseApp(String licenseSource, OceanPluginTypeEnum type)
at Isl.OceanShared.Server.initialise(String licenseSource)
12:58:33 : Stacktrace: 
Server stack trace: 
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size,SocketFlags socketFlags)
at System.Runtime.Remoting.Channels.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[] buffer)
at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16& operation)
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)
at Isl.RemotableObjects.ServerMgmtIF.initialiseApp(String licenseSource, OceanPluginTypeEnum type)
at Isl.OceanShared.Server.initialise(String licenseSource)
12:58:33 : Message   : StackTrace: 
Server stack trace: 
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Runtime.Remoting.Channels.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[] buffer)
at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16& operation)
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)
at Isl.RemotableObjects.ServerMgmtIF.initialiseApp(String licenseSource, OceanPluginTypeEnum type)
at Isl.OceanShared.Server.initialise(String licenseSource)

回答by Haney

This will happen when, as the exception implies, the remote host (server) closes the connection unexpectedly. This can be due to a multitude of reasons, but typically is due to an unhandled exception on the server side. Investigate the server code and go from there.

这将发生在异常情况下,远程主机(服务器)意外关闭连接。这可能是由于多种原因造成的,但通常是由于服务器端未处理的异常。调查服务器代码并从那里开始。