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

can't tell if the connection is success #66

Open
SmartTransp opened this issue Nov 17, 2020 · 1 comment
Open

can't tell if the connection is success #66

SmartTransp opened this issue Nov 17, 2020 · 1 comment

Comments

@SmartTransp
Copy link

I have try to check if the connection was OK
and it's working by using this

connection = routeros_api.RouterOsApiPool(IP,user,pass)
print (connection.connected )
api = connection.get.api() ---> I notice that here I get sometimes exceptions , but I can't catch it

but all the time I get "False"( when the router is online and also when the router is offline )
why ?

How can I check if the conneciton is "Alive"?
how do read the "wrong pass" \ Timeout exception ?

did I miss something ?

@argoA
Copy link

argoA commented Jun 10, 2022

You can use a try-except block to catch any exceptions.

try:
   conn = routeros_api.RouterOsApiPool(IP, USER, PASS)
   api = conn.get_api()
except Exception as e:
   print(e)

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