QuantumEntangledAndy / neolink

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

D800 fails to connect #201

Open Saduff opened 7 months ago

Saduff commented 7 months ago

Describe the bug

I have a Reolink D800 that fails to connect. Looking at Wireshark with the dissector, I see that after the TCP handshake, neolink sends a Baichuan login, type 1 packet to which the camera responds with an ACK and then an RST. Not sure if relevant, but the neolink client is on a different VLAN and subnet than the camera and the camera VLAN egress traffic is blocked by a firewall. Reolink Android app for example works fine in this setup.

To Reproduce

  1. Create this configuration file:
    
    bind = "0.0.0.0"

[[cameras]] name = "camera" username = "admin" password = "password" address = "192.168.20.239:9000" discovery = "local"

2. Launch Neolink:

./neolink rtsp --config=neolink.toml

3. Log:

[2023-12-09T08:50:33Z INFO neolink::utils] camera: Connecting to camera at Address: 192.168.20.239:9000 [2023-12-09T08:50:33Z INFO neolink_core::bc_protocol] camera: Trying TCP discovery [2023-12-09T08:50:33Z INFO neolink_core::bc_protocol] camera: Discovery failed [2023-12-09T08:50:33Z WARN neolink::common::camthread] Connection Lost: Failed to connect to camera camera at Address: 192.168.20.239:9000 on channel 0

Caused by:
    Cannot contact camera at given address


**Expected behavior**

Connection succeeds.

**Versions**

NVR software: N/A
Neolink software: `v0.6.2`
Reolink camera model and firmware: D800, FW: `v3.1.0.802_22011003`
Saduff commented 7 months ago

Okay, looking at https://github.com/QuantumEntangledAndy/neolink/discussions/174#discussioncomment-7393946, I see that:

The uid is needed for the hello call to the camera once the ip is know.

So even if the IP is known, the UID is still needed.

Reolink Android app for example works fine in this setup.

What I meant by that is that all the cameras are working fine when adding the Reolink NVR in the app. If I connect to the cameras VLAN, then I can see that the D800 cameras don't have a UID at all and even the Reolink app is not able to connect to the D800 cameras directly. Other models with a UID work fine.

Is it not possible to connect to these cameras then? The only option is through the Reolink NVR? How come https://github.com/thirtythreeforty/neolink mentions that it has been tested with B800/D800? There must be a way since the Reolink NVR can connect to them.

bwthor commented 7 months ago

My D800's connect fine with this code.

bind = "0.0.0.0"

[[cameras]]
name = "Ch1"
username = "admin"
password = "MyPassword"
address = "192.168.0.14"
Saduff commented 7 months ago

My D800's connect fine with this code.

bind = "0.0.0.0"

[[cameras]]
name = "Ch1"
username = "admin"
password = "MyPassword"
address = "192.168.0.14"

Interesting. Are those D800s from the NVR kit or purchased separately? And can you add them via the Reolink Windows client or Android app? I've tried the Android app and it won't connect either. Do they have a UID? Mine don't.

bwthor commented 7 months ago

Yes, they were from an NVR kit, and are connected directly to my regular network using PoE injection. I am not using the NVR in the setup at all. I can connect from any of the Reolink apps, but not with UID, I needed to choose LAN, and they are auto detected there. My RLC-810a has UID, and shows up in the app automatically, only needed to input the correct password. If I recall, I did have to add them, then set the password through the Reolink app before they would work with Neolink.

Saduff commented 7 months ago

I finally found the issue. Apparently the D800s only support one connection at a time. Mine were added to the Reolink NVR channels so the NVR is constantly connected to the cameras. After deleting the camera from the NVR, I could then connect directly to the camera with the official Reolink app. Then, if you try to add it back to the NVR, the connection will fail as long as the app is open and streaming. Once you close the app, the NVR can connect again. Then if you reopen the app, the stream will fail to load again. This confirms there can only be one connection. Knowing this, I got Neolink working as well.

I didn't find any documentation about this, just a comment from someone after searching the internet that tipped me off about the connection limit. I feel like there should be a troubleshooting section in the documentation that mentions this.

MRobi1 commented 6 months ago

Having the same issue with the B800 cams, but I'm connecting through the NVR instead. It will work for a few days, then out of nowhere it starts giving the same errors. Sometimes I can restart neolink and it works for a while, other times I have to restart the NVR itself.

Dec 16 20:04:40 neolink neolink[1294]: [2023-12-16T20:04:40Z INFO  neolink::common::camthread] Attempt>
Dec 16 20:04:40 neolink neolink[1294]: [2023-12-16T20:04:40Z INFO  neolink::utils] shed: Connecting to>
Dec 16 20:04:40 neolink neolink[1294]: [2023-12-16T20:04:40Z INFO  neolink_core::bc_protocol] shed: Tr>
Dec 16 20:04:40 neolink neolink[1294]: [2023-12-16T20:04:40Z INFO  neolink_core::bc_protocol] shed: Di>
Dec 16 20:04:40 neolink neolink[1294]: [2023-12-16T20:04:40Z WARN  neolink::common::camthread] Connect>
Dec 16 20:04:40 neolink neolink[1294]:     
Dec 16 20:04:40 neolink neolink[1294]:     Caused by:
Dec 16 20:04:40 neolink neolink[1294]:         Cannot contact camera at given address
QuantumEntangledAndy commented 2 months ago

Probably late here but I'll address what I can. The UID is only needed on UDP connections not TCP over port 9000.

When connecting to a NVR you point neolink towards the NVRs ip addresses not the cameras. You can use the channel option if you have multiple cameras on the same NVR.

In neolink we only open one connection to the camera and try to stream both sub and main through it but if that fails you should try setting it up to only stream one of them.

Saduff commented 2 months ago

Thanks for clarifying.

When connecting to a NVR you point neolink towards the NVRs ip addresses not the cameras.

I probably didn't try that because my use case was about potentially getting rid of the NVR, so I needed the direct connection to cameras to work. But as it turned out, nothing else can connect directly to cameras while the NVR is still connected. It doesn't even have to be the NVR. If you have a Reolink client actively streaming directly from the camera, Neolink will likewise not be able to connect.

However, I've kept the NVR and can get the RTSP streams from it, so I have no need for Neolink. It's still a good option to have available though.

I feel like there should be a troubleshooting section in the documentation that mentions this.

I was going to close this issue after figuring out my issue, but I kept it open for that reason. I still believe it would be a good idea to mention this somewhere in the documentation since I probably wasn't the first nor will I be the last person to run into this.