Community discussions

MikroTik App
Forum Guru
Forum Guru
Topic Author
Posts: 1305
Joined: Sun Sep 18, 2011 7:00 pm

python API - how to know if connection is OK?

Mon Nov 16, 2020 10:08 am

Hello ,
when I connect to my router I use
import routeros_api
connection = routeros_api.RouterOsApiPool(Router_IP, username='admin', password='mypass')
how can I tell if the connection OK , or if there ware probkem in the user\pass\address
when I print the connection I get this :
<routeros_api.api.RouterOsApiPool object at 0xb5ead070>
for example -
I want to know if the password is wrong -and then pring "Wrong pass"
or if hte router is not online \ can't connect to it

Also so I have try to use this to know if I manage to connect to the router :
print (connection.connected)
but it return me "False" all the time , when I'm connected to the router and when I'm not

can someone guide ?

Thanks ,

Who is online

Users browsing this forum: macrokernel and 33 guests