phpnats
phpnats copied to clipboard
Disconnecting after 1 minute
I'm having the same issue as: https://stackoverflow.com/questions/48744861/php-nats-client-disconnects-after-some-idle-time
After connecting, receiving few messages and having some 30 secs idle time, it gets disconnect itself without any interruption. However my Node.js client is working good with the same NATS server.
Not sure what I'm missing.
+1
what version of gnatsd are you running?
latest,
docker run --rm nats -v
nats-server version 1.3.0
looks like that default_stream_timeout (60s) used while connecting
This is indeed caused by the default_stream_timeout
. You can change the timeout with:
$client = new \Nats\Connection();
$client->connect(300); // Or even $client->connect(PHP_INT_MAX);
Or:
ini_set('default_stream_timeout', 300); // Or even ini_set('default_stream_timeout', PHP_INT_MAX);
$client = new \Nats\Connection();
$client->connect();
Large stream timeouts (above 999) are currently not handled properly. PR #132 contains changes to allow larger stream timeouts. I have just created PR #135 with some additional changes to improve the way stream timeouts are handled.
@timsmid could you create a fork with all your PR merged and added to composer registry? Since there is no active maintaining of the library
@timsmid could you create a fork with all your PR merged and added to composer registry? Since there is no active maintaining of the library
You will probably be better of setting up a repository / package yourself. Unfortunately, I have currently no intent to actively maintain or support this library. My fork with the applied timeout changes is publicly available at https://github.com/timsmid/phpnats/tree/develop.
If you have any further questions though, feel free to ask.
@timsmid how to pull your repository with composer?
@timsmid how to pull your repository with composer?
You might be able to reference it directly in your composer.json
file, although I am not entirely sure about the syntax. You can probably use the repositories
key as described in the Composer documentation (https://getcomposer.org/doc/05-repositories.md).
Another alternative is forking my repository and creating a Packagist package yourself. Then you can use your own package in your composer.json
file. That would probably be the sanest route, as you would be in full control of the code.
use like this:
$client->connect(-1);
use like this:
$client->connect(-1);
thanks! seems, it works, but it is slightly ambiguous to permanently write this in queue consumers, right?