Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Start if devices cannot be reached #19

Open
JulianWowra opened this issue Dec 1, 2024 · 6 comments
Open

[FEAT]: Start if devices cannot be reached #19

JulianWowra opened this issue Dec 1, 2024 · 6 comments

Comments

@JulianWowra
Copy link

Hello,
I have a device which unfortunately has poor WLAN reception and is sometimes unreachable.

Current behaviour:
Server is waiting for a response from the configured devices.
Attempting to connect to the 1 configured device(s)...

Expected behaviour:
The server starts, regardless of whether the devices are available.

Question:

  • What happens if devices only come online at a later time?
  • What happens if the WLAN connection is interrupted? Is an attempt made to reach the device again at a later time?
@ClementNerma
Copy link
Owner

The devices are checked at startup to ensure that your configuration file is correct, which prevents surprises later.

This is also how the server works: on startup, it connects to the device, and stores the session internally for all the server's duration.

In case of connection problems, you can manually refresh the session with the /refresh-session?device_name=...

@JulianWowra
Copy link
Author

Sounds good. Thank you for your work.

@JulianWowra
Copy link
Author

The server cannot start if a device cannot be reached. This means that I cannot renew the session at a later time via /refresh-session either...

Tapo-REST-Bridge  | | Attempting to connect to the 2 configured device(s)...
Tapo-REST-Bridge  | | 1 remaining...
Tapo-REST-Bridge  | Error: Failed to login into P110 plug 'P110 - 2': Http(reqwest::Error { kind: Request, url: "http://<< IP >>/app", source: TimedOut })
Tapo-REST-Bridge exited with code 0

How could you solve the problem at startup? Unfortunately, the connection of one device is very unreliable.

How about this?

If a device is not reachable at startup, a warning is written to the log and started anyway. If the device is now requested by a client via the API, another attempt is made to establish a connection. If the device does not match, an error is printed in the log and further requests are rejected directly with an API error?

@JulianWowra JulianWowra reopened this Dec 30, 2024
@ClementNerma
Copy link
Owner

In which context do you need to start the server with the devices not being reachable at that moment?

@JulianWowra
Copy link
Author

If the software crashes or a cyclical restart of the Pi is performed.

Unfortunately, I cannot say exactly when the internet connection to the plug in the device is unstable. That depends on several factors. If the Pi restarts at the moment when the connection is unstable, its server ‘crashes’ again and my software cannot retrieve any data from your interface

@ClementNerma
Copy link
Owner

Hi, sorry for the long delay since the last message.

I'll consider that, but the problem is that it requires to change how the core of the program works. Concretely, it establishes connections on startup to get an "object" that will act as a client interface. Changing it would require to change the structure of how the program works.

I'll see if it can be done, but no promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants