How to debug “could not receive data from client: Connection reset by peer”

前端 未结 3 1886
误落风尘
误落风尘 2021-02-13 20:16

I\'m running a django-celery application on Ubuntu-12.04.

When I run a celery task from my web interface, I get the following error, taken form postgresql-9.3 logfile (m

3条回答
  •  庸人自扰
    2021-02-13 20:41

    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.

    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);
    

    I circumvented the problem by using: ->where("substr(opinion,1,100) = ?",trim(substr($opinion,1,100)))

    This is not a perfect solution, but for my purposes, the select statement using substr() suffices.

    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.

提交回复
热议问题