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

Disconnecting after 1 minute #134

Open
donifer opened this issue Dec 20, 2018 · 11 comments
Open

Disconnecting after 1 minute #134

donifer opened this issue Dec 20, 2018 · 11 comments

Comments

@donifer
Copy link

donifer commented Dec 20, 2018

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.

@fizzka
Copy link

fizzka commented Jan 8, 2019

+1

@byrnedo
Copy link
Contributor

byrnedo commented Jan 9, 2019

what version of gnatsd are you running?

@fizzka
Copy link

fizzka commented Jan 9, 2019

latest,

docker run --rm nats -v
nats-server version 1.3.0

@fizzka
Copy link

fizzka commented Jan 9, 2019

looks like that default_stream_timeout (60s) used while connecting

@timsmid
Copy link

timsmid commented Jan 12, 2019

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.

@rockfridrich
Copy link

@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
Copy link

timsmid commented Feb 24, 2019

@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.

@rockfridrich
Copy link

@timsmid how to pull your repository with composer?

@timsmid
Copy link

timsmid commented Mar 6, 2019

@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.

@youpuyewolong
Copy link

use like this:
$client->connect(-1);

@fizzka
Copy link

fizzka commented Aug 31, 2022

use like this: $client->connect(-1);

thanks!
seems, it works, but it is slightly ambiguous to permanently write this in queue consumers, right?

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

No branches or pull requests

6 participants