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

Script have problems with looping. #1

Closed
choodencio opened this issue Jan 20, 2019 · 2 comments
Closed

Script have problems with looping. #1

choodencio opened this issue Jan 20, 2019 · 2 comments

Comments

@choodencio
Copy link

choodencio commented Jan 20, 2019

Ex. I have 5 devices, written a loop using the script.
` $config =
(new Config())
->set('timeout', 1)
->set('host', $data_tik['tikDDNS'])
->set('user', $data_tik['tikUser'])
->set('pass', $data_tik['tikPass']);

                  $client = new Client($config);
                  $query = new Query('/system/resource/print');
                  $response = $client->write($query)->read();`

If the connection to the second device cannot be connected
The script will stop working immediately.

Can I suggest a code?
If any device connection has a problem, report back and continue working all devices are complete.

@choodencio choodencio changed the title Scripts have problems with looping. Script have problems with looping. Jan 20, 2019
@EvilFreelancer
Copy link
Owner

EvilFreelancer commented Jan 20, 2019

Hello! This is not a bug, script has "exceptions" inside, and on error you'll see the messages from these exceptions. Sample of code for preventing this issue:

use RouterOS\Exceptions\ClientException;

try {
  $client = new Client($config);
  $query = new Query('/system/resource/print');
  $response = $client->write($query)->read();`
} catch(ClientException $e) {
  echo $e->getMessage();
}

@choodencio
Copy link
Author

Thank you.

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