Net_RouterOS interface monitor-traffic

Hi,

I am trying to get real-time traffic data from PPPoE interface.
Tried this below code but it seems I am doing it wrong.
Tried a few ways but no luck.

$request = new RouterOS\Request(‘/interface/monitor-traffic’);
$request->setArgument(‘interface’, ‘’);
$return = $client->sendSync($request);

It’s giving me HTTP ERROR 500

Thank you

sendSync() waits for the command to finish executing. However, “/interface/monitor-traffic” is a continuous command - it never finishes executing until you manually stop it.

You either have to pass the “once” argument to get just one sample in the $return, or use sendAsync() and loop()/completeRequest() in some fashion (e.g. with a callback function, and a loop() with a timer, to get the callback called for however many replies RouterOS returns for the specified number of seconds).