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

Ability to specify connection attempts or timeout #311

Open
ncul777 opened this issue Oct 25, 2024 · 4 comments
Open

Ability to specify connection attempts or timeout #311

ncul777 opened this issue Oct 25, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@ncul777
Copy link

ncul777 commented Oct 25, 2024

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

Running neolink 0.6.3-rc2 on a Raspberry Pi 4B (8GB RAM)

Thanks

@ncul777 ncul777 added the enhancement New feature or request label Oct 25, 2024
@QuantumEntangledAndy
Copy link
Owner

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

@QuantumEntangledAndy
Copy link
Owner

QuantumEntangledAndy commented Oct 26, 2024

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

@QuantumEntangledAndy
Copy link
Owner

QuantumEntangledAndy commented Oct 26, 2024

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

@ncul777
Copy link
Author

ncul777 commented Oct 30, 2024

Thanks for the suggestions.

I added discovery = "local", which does avoid connecting to reolink servers if camera is not found. Note that even if this isn't specified (and no 'addr' set), local discovery is still attempted first and camera found. Either way, the time taken to discover, connect and capture image is typically 5 seconds but have seen a max of 7 seconds. Would there be any way to optimise that?

[2024-10-30T09:20:59Z INFO  neolink::utils] FrontDoor: Connecting to camera at UID: 9527000HX5Q8ICUE
[2024-10-30T09:20:59Z INFO  neolink_core::bc_protocol] FrontDoor: Trying local discovery
[2024-10-30T09:21:00Z INFO  neolink_core::bc_protocol] FrontDoor: Local discovery success 9527000HX5Q8ICUE at 10.42.0.115:40046
[2024-10-30T09:21:00Z INFO  neolink::utils] FrontDoor: Logging in
[2024-10-30T09:21:01Z INFO  neolink::utils] FrontDoor: Connected and logged in
[2024-10-30T09:21:03Z INFO  neolink::common::camthread] FrontDoor: Camera time is already set: 2024-10-30 9:21:01.0 +00:00:00
[2024-10-30T09:21:05Z INFO  neolink::common::neocam] FrontDoor: Model Argus 3E
[2024-10-30T09:21:05Z INFO  neolink::common::neocam] FrontDoor: Firmware Version v3.0.0.3623_24060675

I tried max_discovery_retries = 1 and while that helps with connecting to reolink servers (in this case only one retry attempt), there are still reconnect attempts (even if local discovery is specified). Would it be possible to have a config setting to limit the number of reconnect attempts?

2024-10-30T09:12:46Z INFO  neolink_core::bc_protocol] FrontDoor: Trying local discovery
[2024-10-30T09:13:01Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 1/1
[2024-10-30T09:13:17Z WARN  neolink::common::camthread] FrontDoor: Connection Lost: Failed to connect to camera FrontDoor at UID: 9527000HX5Q8ICUE on channel 0

    Caused by:
        Timed out while waiting for camera reply
[2024-10-30T09:13:17Z INFO  neolink::common::camthread] FrontDoor: Attempt reconnect in 50ms
[2024-10-30T09:13:18Z INFO  neolink::utils] FrontDoor: Connecting to camera at UID: 9527000HX5Q8ICUE
[2024-10-30T09:13:18Z INFO  neolink_core::bc_protocol] FrontDoor: Trying local discovery
[2024-10-30T09:13:33Z INFO  neolink_core::bc_protocol] FrontDoor: Registration with reolink servers failed. Retrying: 1/1
[2024-10-30T09:13:49Z WARN  neolink::common::camthread] FrontDoor: Connection Lost: Failed to connect to camera FrontDoor at UID: 9527000HX5Q8ICUE on channel 0

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

No branches or pull requests

2 participants