New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error reading data. Recevived 0 instead of expected 1 bytes #72
Comments
I can't diagnose it with this information. I also can't reproduce it |
Found this issue too. You can reproduce it by providing a wrong vhost to AMQPConnection. |
What's the point of providing a wrong vhost? |
I mean, when you configure a reabbitmq queue with no vhost and implemnt a vhost like "test" in connection. I hope you could understand me :) |
Code: RabbitMQ (3.0.4): root@myhost:~# rabbitmqctl list_user_permissions test Where is the problem? |
i had the same issue, i have 2 front and rabbitmq is only on one of these, so when the request is held by the second front i had the same message. |
I am connecting to rabbitmq using guest a/c on default vhost "/". Permissions seem to be okay but I am still getting this issue. This happens intermittently on our production boxes and it looks totally undebuggable after "Error reading data. Recevived 0 instead of expected 1 bytes" error. Please help me out here. |
I faced the same error today. After and advice from @videlalvaro saying it was probably related to bad credentials, I found that in my case, it was a wrong vhost: I was using |
Hi, I have access to RabbitMq server through a tunnel, maybe it a cause... UPDATE : it was a configuration error. the port was not good. I entered the web interface port instead of the rabbitMq one... |
Hi, |
Happened to me when I tried to login with bad credentials. |
loostro is correct, I had the same issue, it was bad credentials |
This is caused by error settings of IP, user name, password or port. Needs a mechanism quick timeout and show errors. |
Same here. Host? Right. Credentials? Ok. Vhost? Good. Permissions? Checked. |
@videlalvaro maybe we could have a more informative error message here? |
So, I'm facing the same problem as the original poster. I'll try to fix it as well but if someone has an idea on how to do it, do let me know. |
if you had change rabbitmq guest/guest password, amqplib return that error. |
Yes, I gotta improve the error message at some point. The problem is not changing the |
Hi. I'm pretty sure that I was / am using the right user / pass. It was one Thanks.
|
Then probably to a lack of heartbeats, the socket connection died after being idle for a while. |
I use RabbitMq via Haproxy for failover, then, I had this problem since the connection timeout was too low. You should check all the network softwares/equipments between your client and RabbitMq. Hope this helps. |
@corentin-larose unfortunately for me, my hardware is AWS. Most of the times it's great, sometimes it fails. But even so, I would expect to have a response in one second, which is my current timeout. However it seems that even if I have messages or not on the message queue, I still get the thing to crash and I have no clue how to fix it unfortunately. |
@disniper the problem is with the idle connection, so as long as you have messages going by and the time between two messages is lower than the littlest timeout in your network, then it works. As soon as the idle time (time between two messages) is greater than the littlest timeout in your network, it fails. |
This is interesting and might point to the source of the problem.. This code breaks and from the stack trace logs as far as I can see is not setting the vhost name any where ??
Logs ... ??? is this correct ? PhpAmqpLib\Connection\AbstractConnection->__construct('test', 'test', '/', false, 'AMQPLAIN', NULL, 'en_US', Object(PhpAmqpLib\Wire\IO\StreamIO)) THIS CODE WORKS !!
// done ?? no errors |
I don't use vhost, but have the same problem.
or
|
The default "guest" user can only connect via localhost, by default. I got this 'received 0' error when trying to connect remotely for the first time after testing successfully locally. Setting up a different user solved it for me.
|
Please note, that the user name is also case sensitive. |
Please note, that if you use RabbitMQ behind a Rackspace Cloud Loadbalancer, you should use TCP_STREAM instead of TCP to prevent this issue. Similar settings could probably be used for AWS services. |
@RubenKruiswijk could you please elaborate on this? I can't really see anything useful in Google for "rabbitmq TCP_STREAM". Thank you. |
@dlsniper see http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/protocols.html "TCP Streaming allows either the client or server to send the first message when a connection is established. This option is for protocols where there is no request-response semantic. Either side of the connection can write the first message, with no response being necessarily required or expected." I guess the regular TCP protocol handler of the Rackspace Load Balancer closes the connection earlier because no traffic is sent. |
We also had this issue and it was related with the setup of the HAProxy. It was closing the connections after a short period of time. The solution were found by reading this post: https://deviantony.wordpress.com/2014/10/30/rabbitmq-and-haproxy-a-timeout-issue/ Another solution is to use heartbeats. Hope this helps |
I get this issue when using heartbeats if the process runs over the heartbeat timeout. I'm not sure why it would try reading again without checking the heartbeat first. Actually, I would think there would be an error when trying to ack the message but the connection is closed. |
Is this still an issue? I can't reproduce the problem. |
For me the problem was missing |
mbstring extension is already required in composer.json file, so it should not be an issue anymore. |
@anki-code do you have solved your problem ? i can give u one idea ... see your username and password or vhost |
Just for the record, as @krzysztof-gzocha said, I installed the extension and that fixed my issue. The
Which contains:
Doing a
Which explains my issue - In case anyone else gets the same due to this reason. |
@topikito please open an issue on the symfony/polyfill repository, as this looks like a bug in the polyfill which should be fixed. |
Done @stof symfony/polyfill#63 |
I get this error too (
The messages are consumed, but this error is shown. I'm using RabbitMQ 3.6.5 in a Docker container. PHP is running in a PHP 7 Docker container. I have not found the problem yet, but I'll try to investigate more. If someone has an idea that would be appreciated. |
@michaelperrin
at last good luck! |
@taozywu Thanks for the help. Unfortunately I had to ask on StackOverflow, as I didn't find any solution (http://stackoverflow.com/questions/39640489/error-reading-data-while-executing-a-rabbitmq-consumer-in-symfony). |
AbstractConnection.php protected function wait_frame($timeout = 0)
{
if (is_null($this->input))
{
$this->setIsConnected(false);
throw new AMQPRuntimeException('Broken pipe or closed connection');
}
$currentTimeout = $this->input->getTimeout();
$this->input->setTimeout($timeout);
try {
// frame_type + channel_id + size
$this->wait_frame_reader->reuse(
$this->input->read(AMQPReader::OCTET + AMQPReader::SHORT + AMQPReader::LONG)
);
$frame_type = $this->wait_frame_reader->read_octet();
$class = self::$PROTOCOL_CONSTANTS_CLASS;
if (!array_key_exists($frame_type, $class::$FRAME_TYPES)) {
throw new AMQPRuntimeException('Invalid frame type ' . $frame_type);
}
$channel = $this->wait_frame_reader->read_short();
$size = $this->wait_frame_reader->read_long();
// payload + ch
$this->wait_frame_reader->reuse($this->input->read(AMQPReader::OCTET + (int) $size));
$payload = $this->wait_frame_reader->read($size);
$ch = $this->wait_frame_reader->read_octet();
} catch (AMQPTimeoutException $e) {
$this->input->setTimeout($currentTimeout);
throw $e;
}
$this->input->setTimeout($currentTimeout);
if ($ch != 0xCE) {
throw new AMQPRuntimeException(sprintf(
'Framing error, unexpected byte: %x',
$ch
));
}
return array($frame_type, $channel, $payload);
} SocketIO.php public function read($n)
{
$res = '';
$read = 0;
$buf = socket_read($this->sock, $n);
while ($read < $n && $buf !== '' && $buf !== false) {
// Null sockets are invalid, throw exception
if (is_null($this->sock)) {
throw new AMQPRuntimeException(sprintf(
'Socket was null! Last SocketError was: %s',
socket_strerror(socket_last_error())
));
}
$read += mb_strlen($buf, 'ASCII');
$res .= $buf;
$buf = socket_read($this->sock, $n - $read);
}
if (mb_strlen($res, 'ASCII') != $n) {
throw new AMQPIOException(sprintf(
'Error reading data. Received %s instead of expected %s bytes',
mb_strlen($res, 'ASCII'),
$n
));
}
return $res;
} As you can see, AMQPReader::OCTET + AMQPReader::SHORT + AMQPReader::LONG = 7. this value will be passed to the read function wich will try to read from a socket and according to php documentation: when the queue is empty and rabbit returns nothing a empty string is return from socket_read wich is not 7 bytes long, then the error occurs. its a bug, i dont have time to solve it right now and make a MR, and i'm using stream instad, but thats a shame since sockets are much faster and i needed speed. |
@michaelperrin thank you, answer on stackoverflow fixed my issue. But does that means that we basically unable to use sockets? Isn't it a bug? |
@m0onspell This is probably a bug indeed, but I didn't manage to find what was wrong... That's too bad as the use of sockets would probably result in better performance. |
@michaelperrin |
For me, this problem is impacting consumers only, so i've created 2
connections on the config, for producers i use sockets, since my producers
are called during online calls to my api im getting the performance benefit
of the socket.
The consumers are using streams, but thats not a big problem since i can
scale them on a fair dispatching fashion.
2017-05-23 18:01 GMT-03:00 Michaël Perrin <notifications@github.com>:
… @m0onspell <https://github.com/m0onspell> This is probably a bug indeed,
but I didn't manage to find what was wrong... That's too bad as the use of
sockets would probably result in better performance.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#72 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA9PD4e_Zr0G6QvgRwZ4SSWT5gbSXfbUks5r80ktgaJpZM4Af_A1>
.
|
@michaelperrin I think this got solved via #448 |
Hi, when I try to run
I've got the error after process completed:
What's the problem? Help me please.
The text was updated successfully, but these errors were encountered: