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

Persistent connection #72

Open
lpcs007 opened this issue Mar 20, 2021 · 3 comments
Open

Persistent connection #72

lpcs007 opened this issue Mar 20, 2021 · 3 comments

Comments

@lpcs007
Copy link

lpcs007 commented Mar 20, 2021

I did not understand how to use the persistent connection.
I activated the 5th element and it is generating the persistentId.
But how do I access the API without it opening a new connection?

@boenrobot
Copy link
Member

A connection is still created once when the PHP process starts and persists until the PHP process closes.

How many requests you can handle with the same connection depends on your web server config.

If you are running PHP as an apache module f.e., then PHP is tied to Apache's process, so the connection will only be gone if you restart Apache.

In the case of FastCGI, there's a "recycle" time and number of requests. Whenever a "recycle" occurs, persistent data is lost.

@lpcs007
Copy link
Author

lpcs007 commented Mar 20, 2021

I use Apache module. So it means that the connection remains open until Apache is restarted. Even so, whenever I make a request, a new connection is initiated with mikrotik (but not closed). What I need is for a function to start the connection with mikrotik and when I have a new request, it should be done with the connection that is already open. How do I save this open connection for use in subsequent requests?

ie:

$RadiusServer = new RouterOS\Client('ip', 'user', 'pass', null, true);
$connection = $RadiusServer->persistentId;

if($connection){
  $util = new RouterOS\Util($connection);
  $util->setMenu('/ip arp');
  print_r($util->getAll());
}

@boenrobot
Copy link
Member

There is no persistentId property, so how are you getting that?

Anyway... I'm not entirely sure why that happens. Can you give me your versions involved? Apache version, PHP version, APC(u) version, MikroTik version, OS version? Any one of those could be the cause, as persistent connections are kind of a hack job to be honest.

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

2 participants