球球大作战的颜色代码名字颜色代码复制

查看: 54765|回复: 10
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
金牌会员, 积分 4583, 距离下一级还需 5417 积分
61注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
大家好,最近遇到一个奇怪的问题,一台DELL R 410&&debian 6.0系统的服务器,运行一个apache和vsftp 。现在每隔几天,SSH就登陆不上,报错信息为SSH socket failed: Connection reset by peer。 当然不止SSH,vsftp等也不能连接了的。我telnet这两个服务的端口,都能通。通知机房重启机器后就正常了,过几天后又会出现这个问题。求解,谢谢了!
注册时间最后登录在线时间151 小时阅读权限90积分27465帖子主题精华0UID12570
注册时间最后登录在线时间151 小时阅读权限90积分27465帖子主题精华0UID12570
估计是什么进程导致系统无法写fd了
|汽车报价|微信认证|wifi认证|微信认证|wifi认证|http://wifi.tuan18.org
注册时间最后登录在线时间264 小时阅读权限90积分45874帖子主题精华0UID15810
注册时间最后登录在线时间264 小时阅读权限90积分45874帖子主题精华0UID15810
看ssh的log
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
金牌会员, 积分 4583, 距离下一级还需 5417 积分
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
auth.log里面没有任何报错信息,都是正常登陆的信息。
Apr 21 21:34:01 debian CRON[14699]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 21 21:34:01 debian CRON[14699]: pam_unix(cron:session): session closed for user root
Apr 21 21:35:01 debian CRON[14719]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 21 21:35:01 debian CRON[14721]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 21 21:35:01 debian CRON[14720]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 21 21:35:01 debian CRON[14719]: pam_unix(cron:session): session closed for user root
我看过网上同样报错会出现如下信息:
1,Dec 22 09:43:35 x079-liongao sshd[14892]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key&&
是因为密钥的问题,我日志里面没有任何这种信息,也没有关于打开权限拒绝的信息。
2,还有很多人说将known_hosts文件里面的信息给清空了,这个文件只是个登陆该设备的主机标识,而我从新的IP登陆也是不行的,所以没有做这个操作了。
3,因为上面跑了HTTP和vsftp,而我ulimit设置还是默认的1024,所以今天我将其改成了65535,不知是否是因为TCP连接数过多造成 socket文件打开数到了最大值,因为刚改的,还需要时间观察,大家可以帮我看看是否有这种可能。
注册时间最后登录在线时间269 小时阅读权限90积分46035帖子主题精华0UID10142
注册时间最后登录在线时间269 小时阅读权限90积分46035帖子主题精华0UID10142
我曾经遇到过,/etc/ssh 下的系统文件类似sh_host_dsa_key这些,如果权限变动了会出现SSH socket failed: Connection reset by peer这个提示,默认是600的,可以看/var/log/messages有什么错误提示!
注册时间最后登录在线时间132 小时阅读权限90积分31714帖子主题精华0UID12113
注册时间最后登录在线时间132 小时阅读权限90积分31714帖子主题精华0UID12113
检查下系统负载,磁盘IO,文件数限制。之前服务器也出现过,后面重启就好了,就没再深究
注册时间最后登录在线时间489 小时阅读权限100积分38014帖子主题精华0UID307
注册时间最后登录在线时间489 小时阅读权限100积分38014帖子主题精华0UID307
ssh -vvv 看看
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
金牌会员, 积分 4583, 距离下一级还需 5417 积分
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
看看我的201 发表于
检查下系统负载,磁盘IO,文件数限制。之前服务器也出现过,后面重启就好了,就没再深究 ...
文件数限制已经改过来了,但是磁盘IO和系统负载因为登陆不进去没有看,我写个脚本到时候让他自己执行保存结果到文件看看。我这里是每隔几天就出这个问题,重启也能好。机器就跑了对业务单位提供查询的http和vsftp,访问量不大,除非程序有问题了。
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
金牌会员, 积分 4583, 距离下一级还需 5417 积分
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
源泉星火 发表于
ssh -vvv 看看
谢谢,下次出问题后我就用这个看看
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
金牌会员, 积分 4583, 距离下一级还需 5417 积分
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
本帖最后由 富贵竹555 于
09:48 编辑
又出问题了,这下抓到SSH的连接信息了
[root@dns ~]# ssh -vvv 211.101.40.131
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 211.101.40.131 [211.101.40.131] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.9p1
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer
[root@dns ~]#
从日志信息看,在debug1: SSH2_MSG_KEXINIT sent后终止,这个阶段是SSH连接的第二个阶段双方确认/支持使用的数据加密算法,消息摘要算法,主机公钥等信息的地方,在SSH2_MSG_KEXINIT sent后应该有个SSH2_MSG_KEXINIT&&received接收确认过程,在这个地方中断连接,不知是否有关系,还在研究中,也请大家帮忙分析一下,谢谢!!
(这个ssh连接过程是从这个地方看到的)
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
金牌会员, 积分 4583, 距离下一级还需 5417 积分
注册时间最后登录在线时间51 小时阅读权限70积分4583帖子主题精华0UID11528
在发送一个从debian访问debian机器时ssh的信息,上面为从centos操作的ssh,
root@debian:~# ssh -vvv
OpenSSH_5.5p1 Debian-6+squeeze1, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 211.101.40.131 [211.101.40.131] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug3: Not a RSA1 key file /root/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /root/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze1
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 211.101.40.131
root@debian:~#
Medal No.2
Powered byandroid - java.io.IOException: Connection reset by peer - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
J it only takes a minute:
I'm trying to manage a connection between my phone and another bluetooth device. I'm doing all this using java Android. This is the code I used for connecting the socket using my device:
First I find the Bluetooth device and I create the socket:
BluetoothDevice btNonin =
for (BluetoothDevice device : pairedDevices)
if (device.getName().contains("Nonin"))
// We found the device
// We create the socket
Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
socket = (BluetoothSocket) m.invoke(device, 1);
socket.connect();
catch (Exception e)
Dialogs.showInfoDialog(NONIN_OFF, this);
Afther that I create the data bytes I want the remote bluetooth to receive using some code to convert ASCII to byte:
String[] parts = mensaje.split(" ");
String res = "";
if(parts != null && parts.length & 0)
for (String s : parts)
if (s.length() != 2)
izq = (byte)char2ascii(s.charAt(0));
der = (byte)char2ascii(s.charAt(1));
byte aux2 = (byte)((izq && 4) + der);
res += (char)aux2;
And then I send the data to the bluetooth device:
// We send the data bytes
DataOutputStream dOut = new DataOutputStream(socket.getOutputStream());
dOut.writeBytes(res);
dOut.flush();
Until here it works fine. It sends the data bytes to my device. But then I want to wait for any response from my device, and then I try this:
//Waiting for response
DataInputStream dIn = new DataInputStream(socket.getInputStream());
byte response = '\u0000';
while (dIn.readByte() == '\u0000')
response = dIn.readByte();
Dialogs.showInfoDialog("Response: " + response, this);
catch (Exception e)
Dialogs.showInfoDialog("No se ha recibido respuesta: " + e.toString(), this);
But then, on the line where I make dIn.readByte it shows the message Error:
java.io.IOException: Connection reset by peer
And I don't know why the connection is reset or what happens, as I can debug the line:
DataInputStream dIn = new DataInputStream(socket.getInputStream());
With no mistakes, so I guess the socket is still opened... What is happening here?
Thank you so much for your help!
3,18783869
There are several causes of this problem. The typical cause is that you have written to a connection which has already been closed by the peer. In other words, an application protocol error.
Also your exception handling needs work. If you get any IOException on a socket other than a timeout you must close it, it is dead.
202k17149262
Ok, I tried adding some wait() functions and it seems it works... As it was a problem between timeouts of reading and writing. I think
should work...
3,18783869
remove the line dOut.flush(); this is causing the connection reset.
5,58631730
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled网络协议(107)
转载:/articles/E3amM3
& & & &以前我们经常会碰到Broken pipe或者Connection reset by peer之类的异常,但是tcp实现里什么情况下会抛出这些异常呢?
& & & &在讲具体的原因之前,我们有必要补充下tcp这块的一些基础知识,我们都知道tcp通信有三次握手和四次挥手,网上介绍的文章也一大堆,图我也懒得画了,直接网上找一个图给大家
& & & &三次握手是最前面的三条线表示的过程,&四次挥手是最后面的四条线表示的过程,&里面涉及到几个关键词,SYN,ACK,FIN,MSS,其中SYN是主要用在三次握手过程中的,FIN用在四次挥手过程中,ACK在三次握手和四次挥手过程中的作用就是对收到的SYN和FIN做一个确认,SYN,FIN等存在于TCP头里(tcp报文图也给大家弄了个图,不用再去找啦),0/1表示有无此标记,在tcp实现里后面还会跟一个依次递增的数字,比如上面的J,K等,确认就是递增这些数字(真正的数据报文的ack除外),MSS是表示每一个tcp报文里数据字段的最大长度,不包括tcp头的大小噢&
相信大家看到这两个图会对这些概念有了一个清晰的认识了
& & & 介绍了基础原理之后,再介绍下抓包工具,tcpdump,这工具对你了解tcp的整个过程会非常有帮助,在你无法调试tcp实现的情况下这个工具自然也是必不可少的,具体用法网上有很多介绍,直接从man page上也可以看到详细的介绍,我也不多说啦,下面的截图就是tcpdump根据tcp通信过程获取到的
& & & &这要稍微提下tcpdump的结果和上面的几个过程的对应关系,&前面三条其实就是我们上面所说的三次握手,四次握手过程上面没有完全表现出来,只完成了一半的挥手过程(5,8两条表示的),&里面有几个标识S,F,ack,P,其实还有个R,如果有这些标识那么在tcp头里的SYN,FIN,ACK,PSH,RET分别为1,其中PSH表示要求tcp立即将数据传递给上层,不要做别的什么处理,RET这个表示重置连接,也是和我们今天讨论的问题有很大关系的FLAG,下面会详细介绍
& & & RST的标志位,这个标识为在如下几种情况下会被设置,以下是我了解的情况,可能还有更多的场景,没有验证
当尝试和未开放的服务器端口建立tcp连接时&,服务器tcp将会直接向客户端发送reset报文双方之前已经正常建立了通信通道,也可能进行过了交互,当某一方在交互的过程中发生了异常,如崩溃等,异常的一方会向对端发送reset报文,通知对方将连接关闭当收到TCP报文,但是发现该报文不是已建立的TCP连接列表可处理的,则其直接向对端发送reset报文ack报文丢失,并且超出一定的重传次数或时间后,会主动向对端发送reset报文释放该TCP连接
& & &做了这么些铺垫之后下面进入正题,那么Broken pipe或者Connection reset by peer分别代表什么意思呢,下面从glibc的源码里有对此的介绍
& & & &其实我们java异常里看到的Broken pipe或者Connection reset by peer信息不是jdk或者jvm里定义的,我看到这些关键字往往会首先搜索下jdk或者hotspot源码找到位置进行上下文分析,但是这次没找到,后面才想到应该是linux或者glibc里定义的,果然在glibc离看到了如上的描述和定义
& & & &对于Broken pipe在管道的另外一端没有进程再读的时候就会抛出此异常,Connection reset by peer的描述其实不是很正确,从我的实践来看只描述了一方面,其实在某一端正常close之后,也是可能会有此异常的。
& & & &从我的测试场景是这样的,&共同的前提是客户端向服务端发了数据之后立马调用close关闭socket并进程退出,而服务端在收到客户端的数据之后sleep一会,保证对方的socket已经关闭,接着分别进行两种场景测试
服务端往socket里写一次数据,返回继续做select服务端连续写两次数据,必须保证两次的buffer都是有数据的,也就是保证ByteBuffer的pos和limit要不是一个值
会抛出Connection reset by peer会抛出Broken pipe&
当我们往一个对端已经close的通道写数据的时候,对方的tcp会收到这个报文,并且反馈一个reset报文,tcpdump的结果如下所示,当收到reset报文的时候,继续做select读数据的时候就会抛出Connect reset by peer的异常,从堆栈可以看得出当第一次往一个对端已经close的通道写数据的时候会和上面的情况一样,会收到reset报文,当再次往这个socket写数据的时候,就会抛出Broken pipe了&,根据tcp的约定,当收到reset包的时候,上层必须要做出处理,调用将socket文件描述符进行关闭,其实也意味着pipe会关闭,因此会抛出这个顾名思义的异常
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:2818857次
积分:28179
积分:28179
排名:第147名
原创:75篇
转载:1101篇
评论:176条
(1)(1)(4)(3)(2)(2)(2)(5)(3)(3)(9)(1)(1)(1)(3)(6)(3)(8)(5)(4)(3)(10)(37)(1)(13)(9)(2)(42)(6)(3)(2)(1)(7)(13)(15)(17)(5)(8)(23)(32)(28)(25)(18)(10)(38)(34)(32)(12)(28)(15)(49)(83)(15)(23)(22)(29)(17)(27)(32)(44)(93)(70)(68)(48)

我要回帖

更多关于 球球红色颜色代码复制 的文章

 

随机推荐