Skip to content
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

Endless loop in read operation when using server heartbeat #146

Open
danesteve opened this issue Sep 16, 2020 · 5 comments
Open

Endless loop in read operation when using server heartbeat #146

danesteve opened this issue Sep 16, 2020 · 5 comments
Assignees

Comments

@danesteve
Copy link
Contributor

danesteve commented Sep 16, 2020

After upgrading to v4.6.1 we found that our workers are caught in an endless loop when there are no messages left in the queue.

It only seems to happen when using a server heartbeat lower than the read timeout.

Here is a self contained example showcasing the issue:

<?php

require __DIR__ . '/../vendor/autoload.php';

$connection = new \Stomp\Network\Connection('tcp://127.0.0.1:61613');
$client = new \Stomp\Client($connection);
$stomp = new \Stomp\StatefulStomp($client);

$connection->setReadTimeout(10);

$client->setHeartbeat(0, 5000);
$observer = new \Stomp\Network\Observer\ServerAliveObserver();
$connection->getObservers()->addObserver($observer);

$stomp->subscribe('empty_queue');

var_dump($frame = $stomp->read());// frame will never get printed

$stomp->unsubscribe();

It seems that the issue was introduced in #137. We just downgraded to v4.6.0 for now, but using a heartbeat > readTimeout seems to work too. We are using ActiveMQ.

Regards.

@jmglsn jmglsn self-assigned this Jan 15, 2021
@jmglsn
Copy link
Member

jmglsn commented Jan 15, 2021

Hi @danesteve,
I'll check that but in general it's a good idea to set hb > than any timeout.
Did that not work for your setup?
BR
Jens

@danesteve
Copy link
Contributor Author

Hi @jmglsn, thanks for looking into this.

Yes, i can confirm that using a heartbeat > readTimeout seems to work fine.

@vbkunin
Copy link

vbkunin commented Feb 17, 2021

Hi @jmglsn, I found that using heartbeat > readTimeout doesn't work after 5.0.0 release. Now in this case the HeartbeatException "The server failed to send expected heartbeats" is always thrown. It seems it was introduced in #149.

I checked it with an example https://github.com/stomp-php/stomp-php-examples/blob/support/version-4/src/heartbeats_server.php with readTimeout added.

@Maoxp
Copy link

Maoxp commented Mar 31, 2021

Hi @vbkunin
I also encountered similar problems. How did you solve them in the end? Thank you
image

@vbkunin
Copy link

vbkunin commented Apr 8, 2021

Hi @Maoxp! I've rolled back to the previous version for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants