QuantumEntangledAndy / neolink

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

Custom("missing field `FloodlightStatus`") results in two connection attempts #253

Closed CodeFatherG closed 1 month ago

CodeFatherG commented 1 month ago

Describe the bug

On connecting to the device the following error is given requiring two connection attempts Custom("missing fieldFloodlightStatus").

To Reproduce

Steps to reproduce the behavior. Example:

  1. Create this configuration file:
    
    # Expose on all networks
    bind = "0.0.0.0"

Define RTSP user

[[users]] name = "admin" pass = ...

Front Camera

[[cameras]] name = "front_door_camera" discovery = "local" # Discover local username = "admin" # Camera user password = ... address = "..." # Reserved ip of camera uid = "..." # Camera UID stream = "Main" idle_disconnect = true # Disconnect on idle for battery [cameras.pause] on_motion = true # Should pause when no motion on_client = true # Should pause when no rtsp client [cameras.mqtt] [cameras.mqtt.discovery] topic = "homeassistant" # Enable Discovery with the following controls features = ["Floodlight", "Camera", "Motion", "Reboot", "Battery", "Siren"]

[mqtt] broker_addr = "127.0.0.1" # local broker port = 1883 credentials = ...

2. Launch Neolink:

version: '3.8' services: neolink: image: quantumentangledandy/neolink:latest command: ["/usr/local/bin/neolink", "mqtt-rtsp", "--config=/etc/neolink.toml"] container_name: neolink ports:

Expected behavior

A clear and concise description of what you expected to happen.

Logs

neolink  | [2024-05-11T07:25:18Z INFO  neolink::utils] front_door_camera: Connecting to camera at Address: ..., UID: ...
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol] front_door_camera: Trying TCP discovery
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol] front_door_camera: Trying local discovery
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 255.255.255.255:2015 with tid: 214
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 255.255.255.255:2018 with tid: 71
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 192.168.0.255:2015 with tid: 136
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 192.168.0.255:2018 with tid: 221
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.21.255.255:2015 with tid: 224
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.21.255.255:2018 with tid: 129
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.17.255.255:2015 with tid: 148
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.17.255.255:2018 with tid: 217
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.20.255.255:2015 with tid: 230
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.20.255.255:2018 with tid: 150
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.19.255.255:2015 with tid: 252
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.19.255.255:2018 with tid: 17
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.18.255.255:2015 with tid: 207
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.18.255.255:2018 with tid: 254
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: ...:2018 with tid: 106
neolink  | [2024-05-11T07:25:18Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: ...:2015 with tid: 78
neolink  | [2024-05-11T07:25:19Z INFO  neolink_core::bc_protocol::connection::discovery] Got expected reply
neolink  | [2024-05-11T07:25:19Z INFO  neolink_core::bc_protocol::connection::discovery] Direct connect success at 255.255.255.255:2015 client: -31393138, device: 304
neolink  | [2024-05-11T07:25:19Z INFO  neolink_core::bc_protocol::connection::discovery] Returning direct connect: ConnectResult { addr: ...:39667, client_id: -31393138, camera_id: 304, sid: 0 }
neolink  | [2024-05-11T07:25:19Z INFO  neolink_core::bc_protocol] front_door_camera: Local discovery success ... at ...:39667
neolink  | [2024-05-11T07:25:19Z INFO  neolink::utils] front_door_camera: Logging in
neolink  | [2024-05-11T07:25:21Z INFO  neolink::utils] front_door_camera: Connected and logged in
neolink  | [2024-05-11T07:25:21Z ERROR neolink_core::bc::de] header.msg_id: 291
neolink  | [2024-05-11T07:25:21Z ERROR neolink_core::bc::de] processed_payload_buf: [3C, 3F, 78, 6D, 6C, 20, 76, 65, 72, 73, 69, 6F, 6E, 3D, 22, 31, 2E, 30, 22, 20, 65, 6E, 63, 6F, 64, 69, 6E, 67, 3D, 22, 55, 54, 46, 2D, 38, 22, 20, 3F, 3E, A, 3C, 62, 6F, 64, 79, 3E, A, 3C, 46, 6C, 6F, 6F, 64, 6C, 69, 67, 68, 74, 53, 74, 61, 74, 75, 73, 4C, 69, 73, 74, 20, 76, 65, 72, 73, 69, 6F, 6E, 3D, 22, 31, 2E, 31, 22, 20, 2F, 3E, A, 3C, 2F, 62, 6F, 64, 79, 3E, A]::Ok("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<body>\n<FloodlightStatusList version=\"1.1\" />\n</body>\n")
neolink  | [2024-05-11T07:25:21Z ERROR neolink_core::bc::de] e: Custom("missing field `FloodlightStatus`")
neolink  | [2024-05-11T07:25:23Z WARN  neolink::common::camthread] front_door_camera: Connection Lost: Send Error
neolink  | [2024-05-11T07:25:23Z INFO  neolink::common::camthread] front_door_camera: Attempt reconnect in 400ms
neolink  | [2024-05-11T07:25:23Z INFO  neolink::utils] front_door_camera: Connecting to camera at Address: ..., UID: ...
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol] front_door_camera: Trying TCP discovery
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol] front_door_camera: Trying local discovery
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 255.255.255.255:2015 with tid: 139
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 255.255.255.255:2018 with tid: 40
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 192.168.0.255:2015 with tid: 189
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 192.168.0.255:2018 with tid: 139
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.21.255.255:2015 with tid: 205
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.21.255.255:2018 with tid: 111
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.17.255.255:2015 with tid: 232
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.17.255.255:2018 with tid: 110
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.20.255.255:2015 with tid: 203
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.20.255.255:2018 with tid: 163
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.19.255.255:2015 with tid: 57
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.19.255.255:2018 with tid: 146
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.18.255.255:2015 with tid: 117
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: 172.18.255.255:2018 with tid: 115
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: ...:2018 with tid: 89
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Trying a direct connect to: ...:2015 with tid: 136
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Got expected reply
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Direct connect success at ...:2015 client: -1697458391, device: 305
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol::connection::discovery] Returning direct connect: ConnectResult { addr: ...:39667, client_id: -1697458391, camera_id: 305, sid: 0 }
neolink  | [2024-05-11T07:25:23Z INFO  neolink_core::bc_protocol] front_door_camera: Local discovery success ... at ...:39667
neolink  | [2024-05-11T07:25:23Z INFO  neolink::utils] front_door_camera: Logging in
neolink  | [2024-05-11T07:25:31Z INFO  neolink::utils] front_door_camera: Connected and logged in
neolink  | [2024-05-11T07:25:33Z INFO  neolink::common::camthread] front_door_camera: Camera time is already set: 2024-05-11 17:25:29.0 -10:00:00

Versions

Neolink software: latest Reolink camera model and firmware: Model Argus Eco Ultra v3.0.0.2773_23100910

QuantumEntangledAndy commented 1 month ago

Can you send me a log with debug = true in the [[cameras]] section. It seems this is another issue with the stricter xml parser

QuantumEntangledAndy commented 1 month ago

Ah seems to already be in the logs

<?xml version="1.0" encoding="UTF-8" ?>
<body>
<FloodlightStatusList version=\"1.1\" />
</body>

I'll have to see how to parse this type of empty list in the newer xml parser

CodeFatherG commented 1 month ago

Is my analysis correct that its causing 2 connection requests therefore extending the time of any actions?

Which would cause the issue I am seeing here

QuantumEntangledAndy commented 1 month ago

It counts as a fatal error so it reconnects.

CodeFatherG commented 1 month ago

Should I open a separate issue for the delay experienced in motion making it to mqtt/home assistant? Or is it likely attributed to the double connection time?

QuantumEntangledAndy commented 1 month ago

Let's fix the double connection and then see.

CodeFatherG commented 1 month ago

Excellent. I have no experience in rust or I'd take a look myself. Maybe I'll take a look at some tutorials and see what I can learn.

QuantumEntangledAndy commented 1 month ago

Fix should be pushed now

QuantumEntangledAndy commented 1 month ago

p.s. I'm on holiday for the rest of the week so maybe will be slow replying

CodeFatherG commented 1 month ago

Hi Mate, hope you enjoy your holidays. I know you are just one guy trying to develop and maintain this project, I really appreciate it!

It looks like the double connection is solved. It does not look like the motion delay is resolved, created an issue #257