QuantumEntangledAndy / neolink

An RTSP bridge to Reolink IP cameras
GNU Affero General Public License v3.0
353 stars 49 forks source link

Ability to specify connection attempts or timeout #311

Open ncul777 opened 4 days ago

ncul777 commented 4 days ago

The camera is battery powered Argus 3E. Currently I'm using neolink to capture an image on certain triggers and thats works fine when the camera is online. If however it goes offline (e.g. battery dies, or looses wifi connection), then when image is requested, neolink continually tries to connect (at least for prolonged time) and this blocks the rest of my app (I could of course improve that although not a small job)

$ neolink image --filePath="frontdoor.jpeg" --config cameras.toml FrontDoor
[2024-10-25T15:38:56Z INFO  neolink] Neolink 7158943fc8b86a3d7ffe72248945540ddc4e80f0 release
[2024-10-25T15:38:56Z INFO  neolink::utils] FrontDoor: Connecting to camera at UID: 9527000HX5Q8ICUE
[2024-10-25T15:38:56Z INFO  neolink_core::bc_protocol] FrontDoor: Trying local discovery
[2024-10-25T15:39:11Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 1/10
[2024-10-25T15:39:27Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 2/10
[2024-10-25T15:39:44Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 3/10
[2024-10-25T15:40:00Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 4/10
[2024-10-25T15:40:16Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 5/10
[2024-10-25T15:40:32Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 6/10
[2024-10-25T15:40:49Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 7/10
[2024-10-25T15:41:05Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 8/10
[2024-10-25T15:41:21Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 9/10
[2024-10-25T15:41:37Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 10/10
[2024-10-25T15:41:54Z WARN  neolink::common::camthread] FrontDoor: Connection Lost: Failed to connect to camera FrontDoor at UID: 9527000HX5Q8ICUE on channel 0

Describe the solution you'd like To be able to specify a timeout or number of attempts to try to connect

this being one connection attempt (15 seconds):

[2024-10-25T15:38:56Z INFO  neolink_core::bc_protocol] FrontDoor: Trying local discovery
[2024-10-25T15:39:11Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 1/10

Thanks

QuantumEntangledAndy commented 4 days ago

This is part of a shell script? Why not use it in combination with the timeout shell command

QuantumEntangledAndy commented 3 days ago

If your just referring to the discovery retries you can set it with max_discovery_retries = # in the [[cameras]] section of the config

QuantumEntangledAndy commented 3 days ago

Also if the Argus 3E is on the same network and can ping it directly please add both the uid and the addr and set discovery = "local" to the [[cameras]] config since it will let you connect directly which is usually faster.

[[camera]]
# Usual options like pass etc
uid = "ABCDEFGUID"
addr = "192.168.YOUR_CAM_IP:2018"
discovery = "local"

That will do a local connection only using network pings and brodcasts without making the slow connection to the reolink servers at all. This will of couse only work if it is on the same network