Closed surfzoid closed 1 year ago
Hello,
Interesting ... have you tried adding it and did disabling keep-alive fixed this error for you?
I would assume (this could be completely wrong) that router is just not smart enough to handle more than one admin authenticated session at the time and the error happens at the higher level.
I'm happy to add it if fixed things for you!
Yes i add it, i think about one thing, i hve same problem as you, so i use your scrip in a cron task, but not directly, i use a custom python script whose check the signal.
#! /usr/bin/python
from huawei_lte_api.Client import Client
from huawei_lte_api.AuthorizedConnection import AuthorizedConnection
from huawei_lte_api.Connection import Connection
connection = AuthorizedConnection('http://admin:pass@ip/')
client = Client(connection)
dico=(client.monitoring.status())
quatreG="vas savoir!"
buchette="x"
for key, value in dico.items():
#print(key, " : ", value)
if key == "CurrentNetworkTypeEx" : quatreG=value
if key == "SignalIcon" : buchette=value
if quatreG == "1011":
print("On est en 4G+ : " + quatreG)
else :
print("On est en 4G : " + quatreG)
print("nombre de buchettes: " + buchette)
print("Déconexion : " + client.user.logout())
if buchette <= "2":
restart = '/usr/bin/python3 /home/eric/script/huawei/b618reboot-master/reboot_router.py'
print("Bloquer sur 2 buchettes? On redemarre le router")
os.system(restart)
def reboot(client, server, user, password):
""" reboots the router :) """
verification_token = login(client, server, user, password)
url = "http://%s/api/device/control" % server
headers = {'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
'__RequestVerificationToken': verification_token}
client.post(
url, data='<?xml version:"1.0" encoding="UTF-8"?><request><Control>1</Control></request>', headers=headers)
requests.session().close()
#print("Déconexion : " + client.user.logout())
print("rebooting .....")
Current master (https://github.com/mkorz/b618reboot/commit/b6d7d5b877e9d530424df9cde01e3e34c9fcbf82) should help then. It defaults to current behaviour (keep-alive is turned on), but this could be disabled via config setting.
Hi, by default, request is configured "keep-a-live : true" could you please either add at the end of the reboot ''' requests.session().close() '''
or setup request s = requests.session() s.config['keep_alive'] = False
this will prevent error :already connected when using API with another script in parallel