收到0而不是预期的7个字节AMQPIOException - 用户是正确的,仅当队列为空时

时间:2018-02-27 17:56:04

标签: php symfony rabbitmq

我使用" php-amqplib / rabbitmq-bundle":" ^ 1.14",

控制台命令

 /app/console rabbitmq:consumer  parse_ppmconsumer -m 100

错误是

Message: "Error reading data. Received 0 instead of expected 7 bytes" ["error" => PhpAmqpLib\Exception\AMQPIOException { …},"command" => "rabbitmq:consumer parse_ppmconsumer -m 100","message" => "Error reading data. Received 0 instead of expected 7 bytes"] []

我发现类似的错误,但他们有错误是我检查我的权限:

sudo rabbitmqctl list_permissions -p /
[sudo] password for grek: 
Listing permissions in vhost "/" ...
guest   .*      .*      .*
root    .*      .*      .*

所以正确

情况只有当队列为空时,我才能得到一些数据

/ app / console rabbitmq:consumer parse_ppmconsumer -m 100    00:00,1792631149292 00:00,048967838287354 00:00,037322998046875 00:00,062886953353882 00:00,009692907333374 00:00,02227783203125 00:00,028231859207153 00:00,033851146697998 00:00,0090358257293701 00:00,01706600189209 00:00,012717962265015 00:00,020620107650757 00:00,01526403427124 00:00,016094207763672 00:00,016033887863159 00:00,014401912689209

  • 这是处理时间的每条消息。

最后我得到:

00:00,078952074050903
00:00,12211585044861
00:00,3163890838623
00:00,5457661151886
18:53:27 ERROR     [console] Error thrown while running command "rabbitmq:consumer parse_ppmconsumer -m 100". Message: "Error reading data. Received 0 instead of expected 62 bytes" ["error" => PhpAmqpLib\Exception\AMQPIOException { …},"command" => "rabbitmq:consumer parse_ppmconsumer -m 100","message" => "Error reading data. Received 0 instead of expected 62 bytes"] []


  [PhpAmqpLib\Exception\AMQPIOException]                       
  Error reading data. Received 0 instead of expected 62 bytes  

哪里有问题?

1 个答案:

答案 0 :(得分:0)

我与RabbitMQ消息队列的套接字连接存在同样的问题。 AMQPSocketConnection不支持心跳,因为您可以阅读here

如果要使用套接字来防止此错误,请在配置文件中禁用“heartbeat”参数。

为rabbit_mq包试试此配置:

old_sound_rabbit_mq:
    connections:
        default:
            host:     '%env(resolve:RABBITMQ_HOST)%'
            port:     '%env(resolve:RABBITMQ_PORT)%'
            user:     '%env(resolve:RABBITMQ_USER)%'
            password: '%env(resolve:RABBITMQ_PASSWORD)%'
            vhost:    '/'
            lazy:     false
            connection_timeout: 60
            read_write_timeout: 60
            # requires php-amqplib v2.4.1+ and PHP5.4+
            # keepalive: true
            # requires php-amqplib v2.4.1+
            # heartbeat: 30 - disable heartbeat support
            #requires php_sockets.dll
            use_socket: true # default false

确保已安装mbstring,bcmath和套接字php扩展(这是重要的一步)