QuantumEntangledAndy / neolink

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

Neolink UDP Argus 3 Login doesn't work #10

Closed Subtixx closed 3 years ago

Subtixx commented 3 years ago

Describe the bug Login doesn't work.

To Reproduce

[2021-09-11T14:46:15Z INFO  neolink] Neolink cd9fbc4d859ef90317e932f12f6bf7b82aa250a0 release
[2021-09-11T14:46:16Z INFO  neolink::rtsp] storage shed: Connecting to camera at *CAMERA UID*
[2021-09-11T14:46:16Z INFO  neolink::rtsp] storage shed: Connecting to camera at *CAMERA UID*
[2021-09-11T14:46:18Z ERROR neolink::rtsp] Authentication failed to camera storage shed, not retrying
[2021-09-11T14:46:18Z ERROR neolink_core::bc_protocol::connection::udpconn] Udp write poll aborted
[2021-09-11T14:46:18Z ERROR neolink_core::bc_protocol::connection::udpconn] Udp read poll aborted
[2021-09-11T14:46:18Z ERROR neolink::rtsp] Authentication failed to camera storage shed, not retrying
[2021-09-11T14:46:18Z ERROR neolink_core::bc_protocol::connection::udpconn] Udp read poll aborted
[2021-09-11T14:46:18Z ERROR neolink_core::bc_protocol::connection::udpconn] Udp write poll aborted

Expected behavior Login works.

Versions Neolink software: cd9fbc4 Reolink camera model and firmware: Argus 3 (0130_705_572_474)

QuantumEntangledAndy commented 3 years ago

Could you provide details like your OS how you are running neolink bare metal/docker.

Also debug log might help

export RUST_LOG=debug
neolink rtsp --config=....
QuantumEntangledAndy commented 3 years ago

If you can provide wireshark dumps that would be amazing and really helpful.

Subtixx commented 3 years ago

Running on windows baremetal

notable on the debug logs is only:

[2021-09-11T15:24:55Z DEBUG neolink_core::bc_protocol::connection::udpconn::transmit] Got unexpected discovery packet: UdpDiscovery { tid: 149, payload: UdpXml { c2d_s: None, c2d_c: None, d2c_c_r: Some(D2cCr { timer: Timer { def: 3000, hb: 10000, hbt: 60000 }, rsp: 0, cid: 1671585724, did: 897 }), d2c_t: None, c2d_t: None, d2c_cfm: None, c2d_disc: None, d2c_disc: None, c2m_q: None, m2c_q_r: None, c2r_c: None, r2c_t: None, c2r_cfm: None } }

will provide wireshark dumps if needed to later

QuantumEntangledAndy commented 3 years ago

That's a normal debug message.

Wireshark would be helpful but we should also check that the config.toml is constructed correctly. This could be something simple like it failing to read the username/password fields because of a misspelling or putting it in the wrong place or something.

Subtixx commented 3 years ago

Config is so simple so no I think thats not the problem.

Config:

bind = "0.0.0.0"

[[cameras]]
name = "storage shed"
username = "*MY USERNAME*"
password = "*MY PASSWORD*"
address = "*MY CAMERA UID*"

For wireshark I have to be sure I don't have anything open. I'll probably don't feel like sharing it publicly, so I probably will send it via E-Mail to you.

2 E-Mails have been sent, one with the debug log file and one with the wireshark trace.

If you need anything else let me know.

QuantumEntangledAndy commented 3 years ago

Yes config is pretty simple just need to check the simple things you'd be surprised how many times it's something like that. I'll look into the wireshark when I can. Thank you for sending them.

QuantumEntangledAndy commented 3 years ago

So I have had a look at it and I can't seem to find anything obviously wrong. We have a

Assuming your absolutely certain the password and username are correct then perhaps the argus3 is expecting a different hashing scheme with the NONCE. I am not sure at this point without some serious testing with a live Argus3 and maybe even running the official client through a debugger with breakpoints to show how it combines password and nonce.

Subtixx commented 3 years ago

I've changed the password prior to complaining that it's not working, so yes I'm sure :)

Subtixx commented 3 years ago

Ok im sorry, after I read your message I reset the camera and set it up again. This time with a simpler password 123456. lo and behold the neolink now connects.. HOWEVER a new issue arised. When using VLC it crashes when trying to connect:

[2021-09-12T08:22:23Z INFO  neolink] Neolink cd9fbc4d859ef90317e932f12f6bf7b82aa250a0 release
[2021-09-12T08:22:24Z INFO  neolink::rtsp] igelcam: Connecting to camera at 
[2021-09-12T08:22:24Z INFO  neolink::rtsp] igelcam: Connecting to camera at 
[2021-09-12T08:22:24Z INFO  neolink::rtsp] igelcam: Connected and logged in
[2021-09-12T08:22:24Z INFO  neolink::rtsp] igelcam: Connected and logged in
[2021-09-12T08:22:24Z INFO  neolink::rtsp] igelcam: Starting video stream subStream
[2021-09-12T08:22:24Z INFO  neolink::rtsp] igelcam: Camera time is already set: 2021-09-12 10:22:25 +1
[2021-09-12T08:22:25Z INFO  neolink::rtsp] igelcam: Camera reports firmware version 0130_705_572_474
[2021-09-12T08:22:25Z INFO  neolink::rtsp] igelcam: Starting video stream mainStream
thread '<unnamed>' panicked at 'write_src must be present in created bin', src\rtsp\gst.rs:212:18
stack backtrace:
   0:     0x7ff670437b6f - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff670437b6f - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff670437b6f - std::sys_common::backtrace::_print_fmt
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\sys_common\backtrace.rs:67
   3:     0x7ff670437b6f - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\sys_common\backtrace.rs:46
   4:     0x7ff67044f23a - core::fmt::write
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\core\src\fmt\mod.rs:1110
   5:     0x7ff670430cf8 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\io\mod.rs:1588
   6:     0x7ff67043a746 - std::sys_common::backtrace::_print
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\sys_common\backtrace.rs:49
   7:     0x7ff67043a746 - std::sys_common::backtrace::print
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\sys_common\backtrace.rs:36
   8:     0x7ff67043a746 - std::panicking::default_hook::{{closure}}
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\panicking.rs:208
   9:     0x7ff67043a229 - std::panicking::default_hook
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\panicking.rs:225
  10:     0x7ff67043ada5 - std::panicking::rust_panic_with_hook
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\panicking.rs:622
  11:     0x7ff67043a991 - std::panicking::begin_panic_handler::{{closure}}
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\panicking.rs:519
  12:     0x7ff6704384bf - std::sys_common::backtrace::__rust_end_short_backtrace<closure-0,!>
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\sys_common\backtrace.rs:141
  13:     0x7ff67043a8e9 - std::panicking::begin_panic_handler
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\std\src\panicking.rs:515
  14:     0x7ff67047bee0 - core::panicking::panic_fmt
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\core\src\panicking.rs:92
  15:     0x7ff67047bdd2 - core::option::expect_failed
                               at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633\/library\core\src\option.rs:1243
  16:     0x7ff67013a6cf - alloc::alloc::box_free::h0cdb94b262b53651
  17:     0x7ffc36c88697 - g_cclosure_marshal_VOID__OBJECTv
  18:     0x7ffc36c842cc - g_variant_type_get_gtype
  19:     0x7ffc36c96810 - g_signal_emit_valist
  20:     0x7ffc36c963c8 - g_signal_emit
  21:     0x7ffc36cea631 - gst_rtsp_media_factory_construct
  22:     0x7ffc36cd6574 - gst_rtsp_auth_set_tls_database
  23:     0x7ffc36cd9684 - gst_rtsp_client_set_thread_pool
  24:     0x7ffc36cdb401 - gst_rtsp_client_set_thread_pool
  25:     0x7ffc36cd7e05 - gst_rtsp_client_handle_message
  26:     0x7ffc2f9387a8 - gst_rtsp_connection_write_usec
  27:     0x7ffbc7de5d81 - g_main_depth
  28:     0x7ffbc7de45e0 - g_main_context_dispatch
  29:     0x7ffbc7de4bc2 - g_main_context_is_owner
  30:     0x7ffbc7de61f3 - g_main_loop_run
  31:     0x7ffc36d029d8 - gst_rtsp_stream_transport_set_url
  32:     0x7ffbc7dc72be - g_thread_pool_stop_unused_threads
  33:     0x7ffbc7dc67fe - g_thread_new
  34:     0x7ffbc7def727 - g_rw_lock_writer_unlock
  35:     0x7ffc4f4e1bb2 - configthreadlocale
  36:     0x7ffc4fd27034 - BaseThreadInitThunk
  37:     0x7ffc51a22651 - RtlUserThreadStart

EDIT: Reinstalled gstreamer, didn't help unfortunetly. But im really grateful for the help!

QuantumEntangledAndy commented 3 years ago

When you reinstalled gstreamer did you select typical or complete? It needs to be complete. Also need to set the environmental variable for gstreamer as indicated in the readme.

Also once you've ensured thats true. Could you run it with get debug mode

export GST_DEBUG=3

Post the logs although it's usually quite long.

Subtixx commented 3 years ago

First time I installed gstreamer I used complete and didnt set the env var, second time I used chocolatey to install it and it set the env var.

Log: https://gist.github.com/Subtixx/fe1c38bfe810dfe16beb4d9fbce10de2

QuantumEntangledAndy commented 3 years ago

Your log is typical of an incomplete gstreamer installation. It can't find all the needed gstreamer plugins and this causes it to error.

QuantumEntangledAndy commented 3 years ago

What is your value of GSTREAMER_1_0_ROOT_X86_64 and your PATH variable. I wonder if mixing msi and chocolaty caused it to set something up a little oddly.

Subtixx commented 3 years ago

hmm thats weird..

Didnt had a GSTREAMER_1_0_ROOT_X86_64 only GSTREAMER_1_0_ROOT_MSVC_X86_64

GSTREAMER_1_0_ROOT_MSVC_X86_64 E:\gstreamer\1.0\msvc_x86_64\

PATH %GSTREAMER_1_0_ROOT_MSVC_X86_64%\bin

EDIT: Just installed gstreamer over the choco install with "complete" again. Same issue. I also added GSTREAMER_1_0_ROOT_X86_64 manually.

EDIT2: gst-inspect-1.0.exe returns Total count: 189 plugins, 1449 features

and these "issues"

0:00:01.066336000 15740 000001A00ABB8CF0 WARN                 default ges-meta-container.c:237:_set_value:<GESAsset@000001A00ABB3DE0> Could not set value on item: format-version
0:00:01.071823000 15740 000001A00ABB8CF0 WARN                 default ges-meta-container.c:237:_set_value:<GESAsset@000001A00ABB3E60> Could not set value on item: format-version
0:00:01.078858000 15740 000001A00ABB8CF0 WARN                 default ges-meta-container.c:237:_set_value:<GESAsset@000001A00ABB3EE0> Could not set value on item: format-version
0:00:01.085629000 15740 000001A00ABB8CF0 WARN               structure gststructure.c:2332:priv_gst_structure_parse_fields: Failed to find delimiter, r=mimetype
0:00:01.270533000 15740 000001A00ABB8CF0 WARN                  ladspa gstladspa.c:508:plugin_init:<plugin90> no LADSPA plugins found, check LADSPA_PATH
0:00:01.537926000 15740 000001A00ABB8CF0 WARN             d3d11device gstd3d11device.c:780:gst_d3d11_device_constructed:<d3d11device4> Couldn't create d3d11 device with debug flag
0:00:01.873368000 15740 000001A00F6D9340 WARN             mftransform gstmftransform.cpp:552:gst_mf_transform_thread_func:<mftransform3> No available device at index 0
0:00:01.901076000 15740 000001A00F6D9380 WARN             mftransform gstmftransform.cpp:552:gst_mf_transform_thread_func:<mftransform4> No available device at index 0
0:00:01.945363000 15740 000001A00F6D9480 WARN             mftransform gstmftransform.cpp:552:gst_mf_transform_thread_func:<mftransform6> No available device at index 0
0:00:01.955959000 15740 000001A00F6D9580 WARN             mftransform gstmftransform.cpp:552:gst_mf_transform_thread_func:<mftransform8> No available device at index 1
0:00:01.962022000 15740 000001A00F6D95C0 WARN             mftransform gstmftransform.cpp:552:gst_mf_transform_thread_func:<mftransform9> No available device at index 0
0:00:01.976000000 15740 000001A00F6D9480 WARN             mftransform gstmftransform.cpp:552:gst_mf_transform_thread_func:<mftransform11> No available device at index 1
0:00:02.416170000 15740 000001A00ABB8CF0 WARN                 default gstnvrtcloader.c:94:gst_nvrtc_load_library: Could not open library nvrtc64_114_0.dll, 'nvrtc64_114_0.dll': The specified module could not be found.
QuantumEntangledAndy commented 3 years ago

There is something up with this because it cannot seem to find any plugins. Not even the core plugin that make the queue element. I don't have a Windows so I'm not sure what debugging steps to take to fix this sort of error.

Can you confirm that %GSTREAMER_1_0_ROOT_MSVC_X86_64%\bin has the core gstreamer plugin?

Subtixx commented 3 years ago

I don't know what you mean by Can you confirm that %GSTREAMER_1_0_ROOT_MSVC_X86_64%\bin has the core gstreamer plugin?

You mean this?

coreelements:  capsfilter: CapsFilter
coreelements:  clocksync: ClockSync
coreelements:  concat: Concat
coreelements:  dataurisrc: data: URI source element
coreelements:  downloadbuffer: DownloadBuffer
coreelements:  fakesink: Fake Sink
coreelements:  fakesrc: Fake Source
coreelements:  fdsink: Filedescriptor Sink
coreelements:  fdsrc: Filedescriptor Source
coreelements:  filesink: File Sink
coreelements:  filesrc: File Source
coreelements:  funnel: Funnel pipe fitting
coreelements:  identity: Identity
coreelements:  input-selector: Input selector
coreelements:  multiqueue: MultiQueue
coreelements:  output-selector: Output selector
coreelements:  queue: Queue
coreelements:  queue2: Queue 2
coreelements:  streamiddemux: Streamid Demux
coreelements:  tee: Tee pipe fitting
coreelements:  typefind: TypeFind
coreelements:  valve: Valve element
coretracers:  latency (GstTracerFactory)
coretracers:  leaks (GstTracerFactory)
coretracers:  log (GstTracerFactory)
coretracers:  stats (GstTracerFactory)
Subtixx commented 3 years ago

Ok guess you're right. Just tried it with a debian VM and there it works flawlessly. Thank you for your help!

Does the battery drain issue still occur?

QuantumEntangledAndy commented 3 years ago

You could also try increasing the log level in GST_DEBUG and see what it reports when trying to load plugins which should be near the top of the logs. But I don't remeber the details of what log level is needed so youd have to experiment a bit with it.

I think we should try telling gstreamer exactly where the plugins are with GST_PLUGIN_SYSTEM_PATH as described in the docs

QuantumEntangledAndy commented 3 years ago

This branch will still have the battery drain issues. I'm waiting for the UDP and motion PRs to get merged before I try tackling that one.