Giter Club home page Giter Club logo

Comments (6)

Salamek avatar Salamek commented on May 28, 2024

We should probably deprecate that option (throw deprecation warning when True), keep it that way like ~2 versions and then drop it completely... that means remove condition on line:

I bet that no one is using login_on_demand=True anyway (my code is also not using it)...

from huawei-lte-api.

arekm avatar arekm commented on May 28, 2024

Looking for a replacement for (what I assume) on demand was doing. My script runs 24h and checks lte status on router - when it's bad then forces reconnect with set_mobile_dataswitch or does reboot. Now I'm getting exception with "100003: No rights (needs login)" message after each 5 minutes.

So, is timeout in AuthorizedConnection used for anything? I would assume that it relogs in when something is executed after timeout passes but enforce_authorized_connection() is not called anywhere. It is supposed to be manually called?

Edit: based on https://github.com/home-assistant/core/blob/dev/homeassistant/components/huawei_lte/__init__.py#L193 it is supposed to be called manually.

from huawei-lte-api.

Salamek avatar Salamek commented on May 28, 2024

@arekm well there is RFC PR #96 with changes to handle all this but it needs some polishing and i don't have time right now, i will try to look at it next weeek...

from huawei-lte-api.

arekm avatar arekm commented on May 28, 2024

Ok. Just a note that

AuthorizedConnection()
Client()
try:
  dosomething
except  ResponseErrorLoginRequiredException:
  connection.enforce_authorized_connection()

doesn't relog us in if router is rebooted (in middle of "dosomething", even with just client.device.reboot()) and thus we aren't logged in anymore. enforce_authorized_connection() has no knowledge if we are actually logged in in router (only knows if API thinks we are logged in).

So the only safe thing to do as client is to:

except  ResponseErrorLoginRequiredException:
  # full connection again
  AuthorizedConnection()
  Client()

I don't see "logout" in API, so ugly

except  ResponseErrorLoginRequiredException:
  auth_conn.logged_in = False
  connection.enforce_authorized_connection()

would also work.

from huawei-lte-api.

Salamek avatar Salamek commented on May 28, 2024

@arekm 1.5 is out with context manager and option to close session...
so you can do

with Connection('url') as connection:
    client = Client(connection)
    # Do stuff

# auto logout & close session

or

connection = Connection('url')
client = Client(connection)
# Do stuff

connection.close() # manually logout & close session

Let me know if this release solves your issues....

from huawei-lte-api.

Salamek avatar Salamek commented on May 28, 2024

And login_on_demand has been deprecated and has no effect, it will be removed in next major release, so closing this for now

from huawei-lte-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.