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

Can't Connect Through NVR #92

Closed
MRobi1 opened this issue Nov 23, 2020 · 18 comments
Closed

Can't Connect Through NVR #92

MRobi1 opened this issue Nov 23, 2020 · 18 comments
Labels
bug Something isn't working

Comments

@MRobi1
Copy link

MRobi1 commented Nov 23, 2020

Describe the bug
Trying to connect to cameras that are connected to Reolink NVR. Is this even possible or must the be connected to a POE switch? I want to use the Reolink NVR but want to access the HD stream for tinycam on my TV since there is no Reolink AndroidTV app.

Error I'm getting:
[2020-11-23T23:39:03Z INFO neolink] Pool: Connecting to camera at 172.16.25.6:9000 [2020-11-23T23:39:03Z INFO neolink] Side Yard: Connecting to camera at 172.16.25.2:9000 [2020-11-23T23:39:03Z INFO neolink] Pool: Connecting to camera at 172.16.25.6:9000 [2020-11-23T23:39:03Z INFO neolink] Side Yard: Connecting to camera at 172.16.25.2:9000 [2020-11-23T23:39:08Z ERROR neolink] Error streaming from camera Pool, will retry in 8s: Connection error [2020-11-23T23:39:08Z ERROR neolink] Error streaming from camera Pool, will retry in 8s: Connection error [2020-11-23T23:39:08Z ERROR neolink] Error streaming from camera Side Yard, will retry in 8s: Connection error [2020-11-23T23:39:08Z ERROR neolink] Error streaming from camera Side Yard, will retry in 8s: Connection error

To Reproduce
Steps to reproduce the behavior. Example:

  1. Create this configuration file:
bind = "0.0.0.0"
[[cameras]]
name = "Side Yard"
username = "xyz"
password = "abcdefg"
[[cameras]]
name = "Pool"
username = "xyz"
password = "abcdefg"
address = "172.16.25.6:9000"
  1. Launch Neolink:
  2. Check logs

Expected behavior
Neolink to connect

Versions
NVR software: Reolink NVR RLN16-410 f/w version 20102145
Neolink software: pulled docker container today
Reolink camera model and firmware: Reolink B800 f/w version 17_20042200

@MRobi1 MRobi1 added the bug Something isn't working label Nov 23, 2020
@MRobi1
Copy link
Author

MRobi1 commented Nov 24, 2020

Added debug log, doesn't seem to give much more detail

[2020-11-24T00:15:16Z INFO neolink] Neolink 0.3.0 (unknown commit) release [2020-11-24T00:15:16Z DEBUG neolink::gst] Permitting anonymous to access /Side Yard, /Side Yard/mainStream [2020-11-24T00:15:16Z DEBUG neolink::gst] Permitting anonymous to access /Pool, /Pool/mainStream [2020-11-24T00:15:16Z INFO neolink] Side Yard: Connecting to camera at 172.16.25.2:9000 [2020-11-24T00:15:16Z INFO neolink] Pool: Connecting to camera at 172.16.25.6:9000 [2020-11-24T00:15:21Z ERROR neolink] Error streaming from camera Side Yard, will retry in 1s: Connection error [2020-11-24T00:15:21Z ERROR neolink] Error streaming from camera Pool, will retry in 1s: Connection error [2020-11-24T00:15:22Z INFO neolink] Side Yard: Connecting to camera at 172.16.25.2:9000 [2020-11-24T00:15:22Z INFO neolink] Pool: Connecting to camera at 172.16.25.6:9000 [2020-11-24T00:15:27Z ERROR neolink] Error streaming from camera Pool, will retry in 2s: Connection error [2020-11-24T00:15:27Z ERROR neolink] Error streaming from camera Side Yard, will retry in 2s: Connection error

@QuantumEntangledAndy
Copy link
Collaborator

This may be related to the error we had with aac audio. Can you turn of audio using the official client and try again.

@MRobi1
Copy link
Author

MRobi1 commented Nov 24, 2020

I disabled audio and same message in the logs.

Should I be able to ping the cameras from the host machine or would the NVR have some sort of built-in firewall to block that? I tried pinging them from 3 different systems and they don't seem reachable on any. I'm thinking that may be part of my problem

@QuantumEntangledAndy
Copy link
Collaborator

I see well NVR is certaintly possible @twistedddx uses them himself. I am not sure how messages are routed through the NVR so I wouldn't know about the ping. Are you using multiple channels on your NVR? If so please also set the channel = num setting in the config

@QuantumEntangledAndy
Copy link
Collaborator

Also please set the envirmonetal var GST_DEBUG=3 for even more logging.

@MRobi1
Copy link
Author

MRobi1 commented Nov 24, 2020

environmental var GST_DEBUG=3 was already set with the second set of logs.

Yes I am using multiple channels on the NVR.
added channel = "6" and still get the same error.

But that gave me another idea. I entered the IP of the NVR instead and chose a different channel. Doing this I'm getting a "Connected and logged in" but when I try to connect to the rtsp stream it's got a data rate of 0Kb/s so I'm guessing this isn't the right way to go.

@QuantumEntangledAndy
Copy link
Collaborator

I beleive that connecting to the NVR is correct. Is there anything in the log when doing it this way?

@twistedddx
Copy link
Contributor

You can't reach the 172.16.25.x network that exists on the poe switch side of the nvr through the nvr's wan port.
Eg you can not directly reach the cameras via ip through the nvr.

Your pc can be physically connected to the poe ports and statically assigned on the 172.16.25.x network to direct connect to cameras.

But more likely you should point neolink to the nvr's ip / port and then use the channel_id setting.
This will use the nvr as a proxy to the cameras.

@QuantumEntangledAndy
Copy link
Collaborator

Ah channel_id not channel.... sorry :(, I should have checked first

@MRobi1
Copy link
Author

MRobi1 commented Nov 24, 2020

Getting somewhere. I'm getting video streams, when connecting via TCP I'm getting a segmentation fault (log below). When connecting via UDP I get video. But it's not the right channel.

`[2020-11-24T02:47:14Z INFO neolink] Neolink 0.3.0 (unknown commit) release

[2020-11-24T02:47:14Z INFO neolink] Shed: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] SideYard: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] SideYard: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] Shed: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] SideDoor: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] SideDoor: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] BackDoor: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] BackDoor: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] HotTub: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] HotTub: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] Pool: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:14Z INFO neolink] Pool: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:47:15Z INFO neolink] Shed: Connected and logged in

[2020-11-24T02:47:15Z INFO neolink] SideYard: Connected and logged in

[2020-11-24T02:47:15Z INFO neolink] SideYard: Starting video stream subStream

[2020-11-24T02:47:15Z INFO neolink] Shed: Connected and logged in

[2020-11-24T02:47:15Z INFO neolink] Shed: Starting video stream subStream

[2020-11-24T02:47:15Z INFO neolink] SideYard: Connected and logged in

[2020-11-24T02:47:15Z INFO neolink] BackDoor: Connected and logged in

[2020-11-24T02:47:15Z INFO neolink] BackDoor: Starting video stream subStream

[2020-11-24T02:47:15Z INFO neolink] HotTub: Connected and logged in

[2020-11-24T02:47:15Z INFO neolink] HotTub: Starting video stream subStream

[2020-11-24T02:47:15Z INFO neolink] HotTub: Connected and logged in

[2020-11-24T02:47:15Z INFO neolink] Shed: Camera time is already set: 2020-11-23 22:47:15 -4

[2020-11-24T02:47:15Z INFO neolink] Shed: Starting video stream mainStream

[2020-11-24T02:47:15Z INFO neolink] SideYard: Camera time is already set: 2020-11-23 22:47:15 -4

[2020-11-24T02:47:15Z INFO neolink] SideYard: Starting video stream mainStream

[2020-11-24T02:47:15Z INFO neolink] HotTub: Camera time is already set: 2020-11-23 22:47:15 -4

[2020-11-24T02:47:15Z INFO neolink] HotTub: Starting video stream mainStream

[2020-11-24T02:47:16Z INFO neolink] SideDoor: Connected and logged in

[2020-11-24T02:47:16Z INFO neolink] Pool: Connected and logged in

[2020-11-24T02:47:16Z INFO neolink] Pool: Connected and logged in

[2020-11-24T02:47:16Z INFO neolink] Pool: Starting video stream subStream

[2020-11-24T02:47:16Z INFO neolink] BackDoor: Connected and logged in

[2020-11-24T02:47:16Z INFO neolink] SideDoor: Camera time is already set: 2020-11-23 22:47:16 -4

[2020-11-24T02:47:16Z INFO neolink] SideDoor: Starting video stream mainStream

[2020-11-24T02:47:16Z INFO neolink] BackDoor: Camera time is already set: 2020-11-23 22:47:16 -4

[2020-11-24T02:47:16Z INFO neolink] BackDoor: Starting video stream mainStream

[2020-11-24T02:47:16Z INFO neolink] Pool: Camera time is already set: 2020-11-23 22:47:16 -4

[2020-11-24T02:47:16Z INFO neolink] Pool: Starting video stream mainStream

[2020-11-24T02:47:18Z INFO neolink] SideDoor: Connected and logged in

[2020-11-24T02:47:18Z INFO neolink] SideDoor: Starting video stream subStream

Segmentation fault (core dumped)`

When connecting via UDP it seems stable, but there's something not right with the streams.

[[cameras]]
name = "Shed"
username = "xyz"
password = "abcdefg"
address = "192.168.2.XX:9000"
channel_id = 1

The video for "Shed" is actually showing channel 2. The camera I set as Channel 2 is showing channel 3, Channel 3 shows channel 4, etc...
My last camera, channel 6, doesn't show any video and I get a continuous loop in the log of
`
[2020-11-24T02:53:51Z INFO neolink] Pool: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:53:51Z INFO neolink] Pool: Connected and logged in

[2020-11-24T02:53:51Z INFO neolink] Pool: Camera time is already set: 2020-11-23 22:53:51 -4

[2020-11-24T02:53:51Z INFO neolink] Pool: Starting video stream mainStream

[2020-11-24T02:53:53Z ERROR neolink] Error streaming from camera Pool, will retry in 1s: Timeout

[2020-11-24T02:53:54Z INFO neolink] Pool: Connecting to camera at 192.168.2.58:9000

[2020-11-24T02:53:54Z INFO neolink] Pool: Connected and logged in

[2020-11-24T02:53:54Z INFO neolink] Pool: Starting video stream subStream

`

@QuantumEntangledAndy
Copy link
Collaborator

Is neolink being run inside docker by any chance? We have segmentation faults with docker and TCP sometimes #46.

Udp should work if you bump up your buffer size in your clients (the default buffer often isn't large enough for HD streams).

For the channel 3->4 thing that probably because internally (the protocol) it starts at 0 while the physical numbers you see start at 1.

That last channel 6 might have some sort of other issue going on. Are you still running with debug logs on? If not please connect to just 6 with the debug logs on and post back.

@MRobi1
Copy link
Author

MRobi1 commented Nov 24, 2020

Starting at 0 puts everything right where it should be. It also fixed channel 6 which would have been trying to connect to 7 that didn't exist. Awesome!!!

And yes I'm running it in docker, I'll check out #46 tomorrow since it's late here but sounds like the exact same thing.

Thank you for all the help!

@twistedddx
Copy link
Contributor

You may need to watch for issues with multiple HD streams connecting at once.
I was hitting what appeared to be a connection limit of 2x main streams @ 5mp via NVR to Neolink. I could get 8x sub streams connecting at once. I have also hit what appeared to be connection limits when disconnect and reconnect during testing.

Neolink is slightly different than the official client in how the multiple connections are handled which may cause different limitations to what the official client sees.

@QuantumEntangledAndy
Copy link
Collaborator

QuantumEntangledAndy commented Nov 24, 2020

I recommend you don't use docker if you can help it. With have ubuntu, windows and raspberry pi native builds which will avoid the segfault issues, build are here

@Lanwalker
Copy link

Lanwalker commented Nov 24, 2020 via email

@QuantumEntangledAndy
Copy link
Collaborator

QuantumEntangledAndy commented Nov 24, 2020

You cannot ping with a UUID, UUID is just a number kept on the reolink servers used for coordinating the nat holepunching.

You may also be able to do a broadcast to all ips on the local network and ask every camera "are you this UUID" and then learn the ip from that. Buts its very protocol specific. Not something ping would do

@twistedddx
Copy link
Contributor

twistedddx commented Nov 24, 2020

For those interested this is the setup of IP addressing between NVR and IPC.

After DHCP discovery fails the NVR and IPC exchange IP address via Ethernet II broadcasts.
No subnet or gateway is exchanged, only IP addresses are exchanged.
This exchange is done in 3 packets starting at 20:39:58
The messages include the letters "bc" and are not something I have seen before, I believe this is a BC invented standard.

The NVR never functions as router between its LAN/WAN. The 2 networks are isolated.
I believe much older BC NVR eg very very old Swann devices did not have that LAN/WAN isolation.
Those old devices had a single LAN, so cameras typically got IP address from customers DHCP server and were fully accessible from the users LAN.

There is what I assume a clock sync heartbeat going every 2 seconds, initiated by the NVR.
The heartbeat is ports 2000/3000.

20:39:42 IPC DHCP Discover Requested IP 172.16.25.139
20:39:43 NVR 3000 -> 2000 UDP aaaa0000
20:39:44 IPC DHCP Discover Requested IP 172.16.25.139
20:39:45 NVR 3000 -> 2000 UDP aaaa0000
~20:39:45 (IPC sets random IP 192.168.x.x)
20:39:45 IPC Broadcast ARP request Who has 172.16.25.1? Tell 192.168.x.x
20:39:45 NVR ARP replies 172.16.25.1 is at ec:71:db:xx:xx:xx
20:39:45 IPC DIS port 3000
20:39:47 IPC DHCP Discover Requested IP 172.16.25.139
20:39:47 NVR 3000 -> 2000 UDP aaaa0000
20:39:47 IPC DIS port 3000
20:39:48 NVR Broadcast 0x10bc Ethernet II
20:39:49 NVR 3000 -> 2000 UDP aaaa0000
20:39:49 IPC DIS port 3000
20:39:51 NVR 3000 -> 2000 UDP aaaa0000
20:39:51 IPC DIS port 3000
20:39:53 NVR 3000 -> 2000 UDP aaaa0000
20:39:53 IPC DIS port 3000
20:39:55 NVR 3000 -> 2000 UDP aaaa0000
20:39:55 IPC DIS port 3000
20:39:57 NVR 3000 -> 2000 UDP aaaa0000
20:39:57 IPC DIS port 3000
20:39:58 NVR Broadcast 0x10bc Ethernet II 000000_nvrmac_nvrhexip_00000 // nvrhexip eg ac101901 for 172.16.25.1
20:39:58 IPC Broadcast 0x11bc Ethernet II 000000_nvrmac_nvrhexip_ipcmac_ipchexip_00000 // ipchexip eg c0a824f4 192.168.x.x
20:39:59 NVR 0x16bc Ethernet II 000000_nvrmac_nvrhexip_ipcmac_desiredip_00000 //desiredip eg ac10190a 172.16.25.10
20:39:59 NVR 3000 -> 2000 UDP aaaa0000
~20:39:59 (IPC sets IP 172.16.25.10)
20:39:59 IPC Broadcast ARP request Who has 172.16.25.1? Tell 172.16.25.10
20:39:59 NVR ARP replies 172.16.25.1 is at ec:71:db:xx:xx:xx
20:39.59 IPC DIS port 3000
20:40:01 NVR 3000 -> 2000 UDP aaaa0000
20:40:01 IPC DIS port 3000

@MRobi1
Copy link
Author

MRobi1 commented Nov 24, 2020

I recommend you don't use docker if you can help it. With have ubuntu, windows and raspberry pi native builds which will avoid the segfault issues, build are here

Set it up with the native ubuntu build and had all kinds of stability issues. Crashes, frozen video, green screens, white screens, rainbow lines across the screen. Couldn't figure out for the life of me why. Then I remembered I hadn't stopped the docker container and was trying to run both at the same time on the same machine LOL Once I did that everything seems to be working great! Set it up as a service and I should be good to go from here.

Thanks again for all the help

@MRobi1 MRobi1 closed this as completed Nov 24, 2020
vfdev-5 pushed a commit to vfdev-5/neolink that referenced this issue Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants