现有连接被远程主机强行关闭 [英] An existing connection was forcibly closed by the remote host

查看:105
本文介绍了现有连接被远程主机强行关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个商业应用程序,该应用程序抛出带有消息的 SocketException,

I am working with a commercial application which is throwing a SocketException with the message,

现有连接被远程主机强行关闭

An existing connection was forcibly closed by the remote host

这发生在客户端和服务器之间的套接字连接上.连接正常运行,正在传输大量数据,但随后突然断开连接.

This happens with a socket connection between client and server. The connection is alive and well, and heaps of data is being transferred, but it then becomes disconnected out of nowhere.

有人见过这个吗?原因可能是什么?我可以猜测一些原因,但有没有办法在此代码中添加更多内容以找出可能的原因?

Has anybody seen this before? What could the causes be? I can kind of guess a few causes, but also is there any way to add more into this code to work out what the cause could be?

欢迎提出任何意见/想法.

Any comments / ideas are welcome.

...最新...

我有一些 .NET 跟踪记录,

I have some logging from some .NET tracing,

System.Net.Sockets Verbose: 0 : [8188] Socket#30180123::Send() DateTime=2010-04-07T20:49:48.6317500Z

System.Net.Sockets Error: 0 : [8188] Exception in the Socket#30180123::Send - An existing connection was forcibly closed by the remote host DateTime=2010-04-07T20:49:48.6317500Z 

System.Net.Sockets Verbose: 0 : [8188] Exiting Socket#30180123::Send() -> 0#0

根据日志的其他部分,我看到它说 0#0 表示正在发送一个长度为 0 字节的数据包.但这究竟意味着什么?

Based on other parts of the logging I have seen the fact that it says 0#0 means a packet of 0 bytes length is being sent. But what does that really mean?

正在发生两种可能性之一,我不确定是哪一种,

One of two possibilities is occurring, and I am not sure which,

  1. 连接正在关闭,但数据正在写入套接字,从而产生上述异常.0#0 只是表示没有发送任何内容,因为套接字已经关闭.

  1. The connection is being closed, but data is then being written to the socket, thus creating the exception above. The 0#0 simply means that nothing was sent because the socket was already closed.

连接仍然打开,正在发送一个零字节的数据包(即代码有错误)并且0#0表示正在尝试一个零字节的数据包发送.

The connection is still open, and a packet of zero bytes is being sent (i.e. the code has a bug) and the 0#0 means that a packet of zero bytes is trying to be sent.

你觉得呢?我猜可能没有定论,但也许其他人见过这种事情?

What do you reckon? It might be inconclusive I guess, but perhaps someone else has seen this kind of thing?

推荐答案

这通常意味着远程端关闭了连接(通常通过发送 TCP/IP RST 数据包).如果您正在使用第三方应用程序,可能的原因是:

This generally means that the remote side closed the connection (usually by sending a TCP/IP RST packet). If you're working with a third-party application, the likely causes are:

  • 您正在向应用程序发送格式错误的数据(其中可能包括向 HTTP 服务器发送 HTTPS 请求)
  • 客户端和服务器之间的网络链接由于某种原因中断
  • 您触发了导致崩溃的第三方应用程序错误
  • 第三方应用已耗尽系统资源

很可能第一个案例就是正在发生的事情.

It's likely that the first case is what's happening.

您可以启动 Wireshark 以准确查看线路上发生的情况以缩小问题范围.

You can fire up Wireshark to see exactly what is happening on the wire to narrow down the problem.

如果没有更具体的信息,这里的任何人都不太可能真正为您提供帮助.

Without more specific information, it's unlikely that anyone here can really help you much.

这篇关于现有连接被远程主机强行关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆