faithoflifedev / easy_onvif_workspace

This package works with a variety of ONVIF compatible devices allowing for IP Cameras and NVRs (network video recorders) to be integrated into Dart and Flutter applications.
33 stars 21 forks source link

Actions that require authentication no longer work #58

Closed Hexer10 closed 9 months ago

Hexer10 commented 9 months ago

After the commit https://github.com/faithoflifedev/easy_onvif/commit/89841e43ef5d9d881bc964252c902811e8038d99 every action that requires authentication throws this error:

$ onvif media1 get-profiles

Unhandled exception:
Exception: Error code: {"Code":{"Value":"s:Sender","Subcode":{"Value":{"$":"ter:NotAuthorized"}}},"Reason":{"lang":"en","note":"Wsse authorized time check failed."},"Node":null,"Role":null,"Detail":null}
#0      Transport.sendRequest (package:easy_onvif/src/soap/transport.dart:46:13)
<asynchronous suspension>
#1      Media1.getProfiles (package:easy_onvif/src/media1.dart:96:22)
<asynchronous suspension>
#2      OnvifGetProfiles1MediaCommand.run (package:easy_onvif/src/cmd/onvif_media1_command.dart:178:24)
<asynchronous suspension>
#3      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>

If I downgrade the package to v2.1.2+13 I get the proper output:

$ onvif media1 get-profiles
[{"@token":"MediaProfile00000","@fixed":true,"Name":"MediaProfile_Channel1_MainStream", ...]

I'm running these commands on a Dahua NVR

faithoflifedev commented 9 months ago

@Hexer10, do you know which version you downgraded from?

I just tested with v2.2.0+1 and everything is working as expected. Reading through the changelog it looks like this got resolved for v2.2.0

Hexer10 commented 9 months ago

@faithoflifedev I downgraded from version v2.2.0+2, here is the full terminal output:

$ onvif version
easy_onvif v2.2.0+2

$ onvif media1 get-profiles
Unhandled exception:
Exception: Error code: {"Code":{"Value":"s:Sender","Subcode":{"Value":{"$":"ter:NotAuthorized"}}},"Reason":{"lang":"en","note":"Wsse authorized time check failed."},"Node":null,"Role":null,"Detail":null}
#0      Transport.sendRequest (package:easy_onvif/src/soap/transport.dart:46:13)
<asynchronous suspension>
#1      Media1.getProfiles (package:easy_onvif/src/media1.dart:96:22)
<asynchronous suspension>
#2      OnvifGetProfiles1MediaCommand.run (package:easy_onvif/src/cmd/onvif_media1_command.dart:178:24)
<asynchronous suspension>
#3      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
Unhandled exception:
Exception: Error code: {"Code":{"Value":"s:Sender","Subcode":{"Value":{"$":"ter:NotAuthorized"}}},"Reason":{"lang":"en","note":"Wsse authorized time check failed."},"Node":null,"Role":null,"Detail":null}
#0      Transport.sendRequest (package:easy_onvif/src/soap/transport.dart:46:13)
<asynchronous suspension>
#1      Media1.getProfiles (package:easy_onvif/src/media1.dart:96:22)
<asynchronous suspension>
#2      OnvifGetProfiles1MediaCommand.run (package:easy_onvif/src/cmd/onvif_media1_command.dart:178:24)
<asynchronous suspension>
#3      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>

$ dart pub global activate easy_onvif 2.1.2+13 // <-- Downgrade version
Package easy_onvif is currently active at version 2.2.0+2.
[...]
Building package executables... (2.2s)
Built easy_onvif:onvif.
Installed executable onvif.
Activated easy_onvif 2.1.2+13.

$ onvif version
easy_onvif v2.1.2+13

$ onvif media1 get-profiles
[{"@token":"MediaProfile00000", ...]
faithoflifedev commented 9 months ago

Thanks @Hexer10 for this helpful feedback.

Using easy_onvif v2.2.0+2

Can you run the command:

onvif media1 get-profiles --log-level all

This will show the XML Request/Response communication between the code and the device and hopefully will show what might be causing the issue.

Hexer10 commented 9 months ago

Thanks @Hexer10 for this helpful feedback.

Using easy_onvif v2.2.0+2

Can you run the command:

onvif media1 get-profiles --log-level all

This will show the XML Request/Response communication between the code and the device and hopefully will show what might be causing the issue.

Sure, here is the output https://gist.github.com/Hexer10/680ea4ea489c505b7606163d1b392c75

faithoflifedev commented 9 months ago

HI @Hexer10 ,

I just published easy_onvif: ^2.3.0, I reverted some of the authentication code back to v2.1.2+13.

Hexer10 commented 9 months ago

Hi @faithoflifedev , thanks for your help! Unfortunately I still get the same errors even on v2.3.0+1. If it can help I've uploaded here https://gist.github.com/Hexer10/b0ff9a8bf3784cae32591f9afea588a2 the logs on both v2.1.2+13 and v2.3.0+1, as well as the generated file of onvif debug (on v2.3.0+1).

I also wanted to add that I get this error only on my Dahua NVR, if I try other cams they work fine both on 2.3.0+1 and 2.1.2+13.

faithoflifedev commented 9 months ago

Hi @Hexer10 , thanks for the additional debug info.

Unfortunately, I don't have access to a device that gives the same error. However I believe I've made some progress. Please give my latest release a try and let me know if the issue is resolved.

Hexer10 commented 9 months ago

Thanks a lot for your help! On v3.0.0-dev.1 now it's working properly