Salamek / huawei-lte-api

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

Issue in connecting to Huawei B315s-22 #51

Closed edsub closed 4 years ago

edsub commented 5 years ago

I recently found your project via https://github.com/chenwei791129/Huawei-LTE-Router-SMS-to-E-mail-Sender because I was looking for a way to forward SMS's from my remote (1500km away!) Issue Huawei B315s-22 to either email or another sms number.

I tried to get things running on a RPi running Raspbian Jessie with Python 3.5.7 (previous attempt with 3.5.1 failed with numerous issues). I am hesitating to upgrade to Python 3.7 as my RPi is remote as well and has some other stuff running based n Python 3.5)

I AM aware that my device (Huawei B315s-22) is not on your "tested on" list.

An unauthorized connection ok. But an autorized connectiin attempt throws error 12500 Session error

(note in below log I changed the password to "my_password") The output from the example code on the project main page gives me following output on following statement connection = AuthorizedConnection('http://admin:my_password@192.168.8.1/')

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/Connection.py", line 22, in wrapped
    return fn(*args, **kw)
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/Connection.py", line 175, in get
    return self._check_response_status(self._process_response_xml(response))
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/Connection.py", line 91, in _check_response_status
    error_code
huawei_lte_api.exceptions.ResponseErrorLoginCsrfException: 125002: Session error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "huawei.py", line 7, in <module>
    connection = AuthorizedConnection('http://admin:my_password@192.168.8.1/')
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/AuthorizedConnection.py", line 24, in __init__
    if self.user.login(True):
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/api/User.py", line 76, in login
    state_login = self.state_login()
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/api/User.py", line 27, in state_login
    return self._connection.get('user/state-login')
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/Connection.py", line 25, in wrapped
    return fn(*args, **kw)
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/Connection.py", line 175, in get
    return self._check_response_status(self._process_response_xml(response))
  File "/usr/local/lib/python3.5/site-packages/huawei_lte_api/Connection.py", line 91, in _check_response_status
    error_code
huawei_lte_api.exceptions.ResponseErrorLoginCsrfException: 125002: Session error

Can you give me any hint/clue on how to try to tackle this?

Salamek commented 5 years ago

@edsub only way to debug this is check what calls is official web UI doing on log-in and check what this library is not doing/doing wrong...

JimmyS83 commented 4 years ago

The same for Huawei 3531i-2. I will see if I can help, any hints appretiated :) Its not python 3.5/3.7 related, I have 3.7.3@Raspbian

JimmyS83 commented 4 years ago

3531 use /api/webserver/SesTokInfo for getting session info. I believe whole family of Huwei routers, based on ajax / jquery will be the same ( E5186, E5573Bs-320 etc.).

Following Python works : https://github.com/gallinapassus/huawei-e5186 (after fixing typo in date) Following bash works: https://github.com/cmaion/huawei_router

@Salamek would be nice to add getSession option through /api/webserver/SesTokInfo to your module as well? It could be same case for B315s-22 as well.

taufikterdidik commented 4 years ago

Me too.. I got Session Error on B310 but lucky I program on another pc with vs code (thanks to code completion), and I write this

.... connection = AuthorizedConnection('http://192.168.254.1/', username='admin', password='P@ssw0rd!') .... and it worked, I thinks url with username+password schema not working, so we make it separate parameter..

(sorry for language)

Salamek commented 4 years ago

@taufikterdidik @edsub can you try huawei-lte-api version 1.4.6 ?

Salamek commented 4 years ago

@edsub @JimmyS83 @taufikterdidik closing this, since i think it was resolved in 1.4.7, fell free to comment for issue reopening when this issue is valid for 1.4.7...