Salamek / huawei-lte-api

API For huawei LAN/WAN LTE Modems
GNU Lesser General Public License v3.0
376 stars 92 forks source link

ResponseErrorException: 100006 for hardware CL2E3372HM #159

Closed nipil closed 1 year ago

nipil commented 2 years ago

Hello

I'm trying to use huawei-lte-api 1.6.7 package in a python 3.9.2 virtualenv on debian 11

When running any of the provided examples i get an unknown error response 10006. This error code is not (yet) defined i enums/client.py.

My hardware is a E3372 using HiLink software, with the information below from the web interface :

What can i do to help you diagnost this missing error handling ?

Thanks in advance Nicolas

Salamek commented 2 years ago

Hi, i just tested my E3372 and it works ~fine (well there is small bug in 1.6.7, but it should still work ~):

Maybe try to use version 1.6.4? If it does same thing (huawei-lte-api==1.6.4)...

nipil commented 2 years ago

I just tried the 1.6.4 and is working great, thanks for the idea of reverting to a previous version !

For 1.6.7 here is the full trace (by the way my hardware is not password nor pin protected)

(venv) user@debian:~/huawei-lte-api/examples$ python3 data_dump.py http://192.168.8.1
Traceback (most recent call last):
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/api/User.py", line 61, in _login
    result = self._session.post_set('user/login', {
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/Session.py", line 215, in post_set
    self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/Session.py", line 34, in wrapped
    return fn(*args, **kw)
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/Session.py", line 254, in _post
    response_data = cast(str, self._check_response_status(self._process_response_data(response)))
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/Session.py", line 156, in _check_response_status
    raise error_code_to_exception.get(error_code, ResponseErrorException)(
huawei_lte_api.exceptions.ResponseErrorException: 100006: Unknown

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/huawei-lte-api/examples/data_dump.py", line 33, in <module>
    with Connection(args.url, username=args.username, password=args.password) as connection:
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/Connection.py", line 31, in __init__
    self.user_session = UserSession(self, username, password) if username or password else None
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/api/User.py", line 27, in __init__
    self.user.login(username, password, True)
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/api/User.py", line 112, in login
    return self._login(username, password, PasswordTypeEnum(int(state_login['password_type'])))
  File "/home/user/huawei-lte-api/examples/../huawei_lte_api/api/User.py", line 86, in _login
    raise error_code_to_exception.get(e.code, ResponseErrorException)(
huawei_lte_api.exceptions.ResponseErrorException: 100006: Unknown

Hope it helps

Salamek commented 2 years ago

Yea, thx there were some changes in login/session handling in 1.6.7, we will need to address that...

nipil commented 2 years ago

After reading the discussion in #156, i can confirm that if i reactivate the login with 1.6.7 it works fine with my hardware above

While using default user/pass (admin/admin) i get the following behaviour :

Then i wait for a few minutes and i can run device_info.py --password admin ... successfully again.

nipil commented 2 years ago

One last addition : logout seems to fail on my hardware even with an account set, as shown below :

EDIT: this behaviour is common to 1.6.4 and 1.6.7 when using default account

# ./data_dump.py --username admin --password admin http://192.168.8.1
...
==== Developer.atport_status
100002: No support

Traceback (most recent call last):
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./data_dump.py", line 334, in <module>
    dump(client.developer.atport_status)
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/Connection.py", line 54, in __exit__
    self.close()
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/Connection.py", line 42, in close
    self.user_session.close()
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/api/User.py", line 30, in close
    self.user.logout()
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/api/User.py", line 115, in logout
    return self._session.post_set('user/logout', {
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/Session.py", line 215, in post_set
    self._post(endpoint, data, refresh_csrf, prefix, is_encrypted, is_json)
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/Session.py", line 34, in wrapped
    return fn(*args, **kw)
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/Session.py", line 254, in _post
    response_data = cast(str, self._check_response_status(self._process_response_data(response)))
  File "/home/npillot/huawei-lte-api_1.6.7/examples/./../huawei_lte_api/Session.py", line 156, in _check_response_status
    raise error_code_to_exception.get(error_code, ResponseErrorException)(
huawei_lte_api.exceptions.ResponseErrorWrongSessionToken: 125003: Wrong Session Token
Salamek commented 1 year ago

@nipil can you pls test latest 1.6.9 if it fixes login issue? (it should have same behavior as 1.6.4). I'll look on that logout issue with set login info later...

nipil commented 1 year ago

@Salamek i can confirm that both data_dump and device_info (and my own code) work as intended with 1.6.9, wether it be with authentication enabled or disabled. Only with authentication enabled there is a logout exception. THANKS !

Salamek commented 1 year ago

@nipil good, i'm closing this issue then, logout error is tracked in separate issue #163