PHP API / latency crash

Hello,
I’m using PHP API to communicate with my RB433UL v6.22 with PHP 5.3+ .
the API service is active.
the latency is about 650ms.
I use clear connection on port 8728:

$rosClient = new RouterOS\Client($ip, $login, $pass, 8728, false, 8);

the connexion is ok if i set the timeout up to 4s.
When I do something like

$rosClient->sendAsync(new RouterOS\Request('/interface wireless print', null, 'interface'));
$rosClient->loop();
$responses = $rosClient->extractNewResponses();
... creating response array ....
$rosClient->close();

The script seems to loop with no end and PHP process freezes for about 5minutes.
I can see the log in event in the log of the Rboard but not the log out (via winbox).
If i do the same command with a local board, i get an instant response.
Did someone already encountered this problem? Did you have a trick to pass the command?
Seems to be a stream problem but can’t see where exactly…

the latency is about 650ms.

If by that you mean that a ping takes 650ms per reply, that’s one very unstable link. There’s nothing that can be done on the API side. The network itself needs modification.

The script seems to loop with no end and PHP process freezes for about 5minutes.

But after the 5 minutes, you actually get the list of wireless interfaces? Wow, I knew I made the client be resilient to unstable connections so that you get the reply eventually, but I had never done a successful test with a link THIS unstable.

Did someone already encountered this problem? Did you have a trick to pass the command?

If you use loop() with a timeout, you could gradually print out the list, instead of waiting for it to arrive in whole.

This does not help with the fact you still need to wait 5 minutes for a small list though. That one needs to be fixed on the networking level - some better hardware, more efficient routing settings, closer proximity between the server and router(s), that sort of stuff.

Thanks boen_robot for your answer.
I knew you will ‘tick’ on the network layer :slight_smile: .
This latency is quite standard in satellite level connection, and nothing can really be done for that, i don’t think closer satellite would be secure for people (lol).
However, After the freezing process of PHP, nothing is received.
I checked in the satellite manager and i saw that the API call is recognized as P2P connection (just for your information).
After check, i decided to put a bsdserver between my local board (433UL) and my computer to simulate 700ms latency, and it took approx 10 seconds to answer, so for this part you’re right, it doesn’t seems to come from the API level.

If you use loop() with a timeout, you could gradually print out the list, instead of waiting for it to arrive in whole.

As you asked, i added 1s timeout, but i didn’t receive anythings.

The log in apache2 is:

ever:
Request body read timeout
sometimes:
Broken pipe: core_output_filter: writing data to the network

the apache timeout is set to 300.

Perhaps it’s not a bug, but it seems that i can not use PHP API with our network, so sad… :frowning:
The thing is just why the PHP/Apache process freeze…

thanks for your support

Is SSH recognized and not penalized so severely by any chance? (I’m thinking maybe the satellite provider has decided to simply penalize any unrecognized connections, by counting them as P2P traffic.)

If so, you could create an SSH tunnel between the router and server, and use the API through it. See this post for details on setting it up.

Alternatively, you could make just one web server that is on the other end of the satellite connections, and communicates to other web server(s) via HTTP. The HTTP communications are definitely not going to be penalized.