如何调试“无法从客户端接收数据:对等体重置连接" [英] How to debug "could not receive data from client: Connection reset by peer"
问题描述
我正在Ubuntu-12.04上运行django-celery应用程序.
I'm running a django-celery application on Ubuntu-12.04.
从Web界面运行celery任务时,出现以下错误,形式为postgresql-9.3日志文件(最大日志级别):
When I run a celery task from my web interface, I get the following error, taken form postgresql-9.3 logfile (maximum level of log):
2013-11-12 13:57:01 GMT tss_usr 8113 LOG: could not receive data from client: Connection reset by peer
tss_usr是django应用程序数据库的postgresql用户,(在此示例中)8113是杀死连接的进程的pid.
tss_usr is the postgresql user of the django application database and (in this example) 8113 is the pid of the process who killed the connection, I guess.
您是否了解为什么会发生这种情况,或者至少如何调试此问题?
Have you got any idea on why this happens or at least how to debug this issue?
要使一切恢复正常,我需要重新启动postgresql,这是非常不舒服的.
To make things work again I need to restart postgresql which is extremely uncomfortable.
推荐答案
我知道这是一篇较旧的文章,但我刚刚找到了它,因为今天我的postgres日志中存在相同的错误.我将其范围缩小为PDO select语句.我在Ubuntu Precise上使用Zend Framework 1.10.3.
I know this is an older post, but I just found it because I had the same error today in my postgres logs. I narrowed it down to a PDO select statement. I'm using Zend Framework 1.10.3 on Ubuntu Precise.
如果$ opinion是长文本字符串,则以下pdo语句生成错误.在我的postgres表中,列意见是Text类型.如果$ opinion在一定数量的字符以下,则查询成功.1000个字符可以正常工作.2000个字符失败,并显示无法从客户端接收数据:对等方重置连接".
The following pdo statement generated an error if $opinion is a long text string. The column opinion is type Text in my postgres table. The query succeeds if $opinion is under a certain number of characters. 1000 characters works fine. 2000 characters fails with "could not receive data from client: Connection reset by peer".
$select = $this->db->select()
->from( 'datauserstopics' )
->where("opinion = ?",trim($opinion))
->where("datatopicsid = ?",trim($tid))
->where("datausersid= ?",$datausersid);
$stmt = $this->db->query($select);
我通过使用以下方法解决了这个问题:-> where("substr(opinion,1,100)=?",trim(substr($ opinion,1,100)))
I circumvented the problem by using: ->where("substr(opinion,1,100) = ?",trim(substr($opinion,1,100)))
这不是一个完美的解决方案,但就我的目的而言,使用substr()的select语句就足够了.
This is not a perfect solution, but for my purposes, the select statement using substr() suffices.
请注意,将长字符串插入相同的表/列没有问题.断开连接问题仅出现在文本字符串相对较长的PDO select上.
Note that I have no problem inserting long strings into the same table/column. The disconnect problem only appears for me on the PDO select with relatively long text strings.
这篇关于如何调试“无法从客户端接收数据:对等体重置连接"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!