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

Unhandled Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast on calling Onvif.connect #25

Closed rho558 closed 1 year ago

rho558 commented 1 year ago

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast

0 _$SystemDateAndTimeFromJson (package:easy_onvif/src/model/system_date_and_time.g.dart:12:32)

1 new SystemDateAndTime.fromJson (package:easy_onvif/src/model/system_date_and_time.dart:46:7)

2 _$GetSystemDateAndTimeResponseFromJson (package:easy_onvif/src/model/system_date_time_response.g.dart:12:25)

3 new GetSystemDateAndTimeResponse.fromJson (package:easy_onvif/src/model/system_date_time_response.dart:18:7)

4 _$BodyFromJson (package:easy_onvif/src/model/body.g.dart:43:42)

5 new Body.fromJson (package:easy_onvif/src/model/body.dart:214:55)

6 _$EnvelopeFromJson (package:easy_onvif/src/model/envelope.g.dart:10:18)

7 new Envelope.fromJson (package:easy_onvif/src/model/envelope.dart:20:7)

8 new Envelope.fromXml (package:easy_onvif/src/model/envelope.dart:23:16)

9 Soap.retrieveEnvelope (package:easy_onvif/src/soap.dart:67:21)

#10 DeviceManagement.getSystemDateAndTime (package:easy_onvif/src/device_management.dart:150:22) #11 Onvif.initialize (package:easy_onvif/src/onvif_base.dart:96:22) #12 Onvif.connect (package:easy_onvif/src/onvif_base.dart:87:5) #13 _MyHomePageState._incrementCounter (package:onvif_test/main.dart:52:19)
faithoflifedev commented 1 year ago

Hi @rho558, I just published easy_onvif: ^2.0.13+15 which I believe will resolve the issue. Let me know?

If not, I'll need you to enable debug level logging and give the log results to have enough info for me to properly diagnose the issue.

rho558 commented 1 year ago

@faithoflifedev thank you for replying, unfortunately easy_onvif: ^2.0.13+15 didn't work and the same issue is still there, and after googling and trying to log i don't know how to enable debug level logging, i only get the same exact log as the initial log i posted, do you mind helping me on this one?

faithoflifedev commented 1 year ago

@rho558, the simplest way to get the debug info in this case would be by trying to connect to the onvif device through the supplied onvif cli. In the terminal:

dart pub global activate easy_onvif

onvif authorize #follow the prompts

onvif device-management get-device-information --log-level debug

rho558 commented 1 year ago

Hey, thanks for the help, I'm sorry it took me so long to get back to you. I've tried the cli thing and this is what i got.

� 14:10:56.694824 INFO UI Loggy - Onvif - initializing ... � 14:10:56.710443 DEBUG UI Loggy - DeviceManagement - getSystemDateAndTime � 14:10:56.789062 DEBUG UI Loggy - Onvif - URI: http://192.168.1.2:8000/onvif/device_service � 14:10:56.789062 DEBUG UI Loggy - Onvif - REQUEST: <?xml version="1.0" encoding="UTF-8"?></s:Body></s:Envelope> � 14:10:57.024395 DEBUG UI Loggy - Onvif - RESPONSE: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs=" http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns: timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/a nalytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www. onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:htt p="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsnt="http://docs .oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsnt w="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.o rg/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnsext="htt p://www.meari.com.cn/2011/event/topics" xmlns:extwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl" xmlns:extxsd="http://www.onvifext.com/onvif/ext/ver10/schema"><tds:GetSystem DateAndTimeResponse></tds:SystemDateAndTime> </tds:GetSystemDateAndTimeResponse> </env:Body> </env:Envelope>

Unhandled exception: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast

0 _$SystemDateAndTimeFromJson (package:easy_onvif/src/model/system_date_and_time.g.dart:14:35)

1 new SystemDateAndTime.fromJson (package:easy_onvif/src/model/system_date_and_time.dart:46:7)

2 _$GetSystemDateAndTimeResponseFromJson (package:easy_onvif/src/model/system_date_time_response.g.dart:12:25)

3 new GetSystemDateAndTimeResponse.fromJson (package:easy_onvif/src/model/system_date_time_response.dart:18:7)

4 _$BodyFromJson (package:easy_onvif/src/model/body.g.dart:43:42)

5 new Body.fromJson (package:easy_onvif/src/model/body.dart:214:55)

6 _$EnvelopeFromJson (package:easy_onvif/src/model/envelope.g.dart:10:18)

7 new Envelope.fromJson (package:easy_onvif/src/model/envelope.dart:20:7)

8 new Envelope.fromXml (package:easy_onvif/src/model/envelope.dart:23:16)

9 Soap.retrieveEnvelope (package:easy_onvif/src/soap.dart:67:21)

#10 DeviceManagement.getSystemDateAndTime (package:easy_onvif/src/device_management.dart:150:22) #11 Onvif.initialize (package:easy_onvif/src/onvif_base.dart:96:22) #12 Onvif.connect (package:easy_onvif/src/onvif_base.dart:87:5) #13 OnvifHelperCommand.initializeOnvif (package:easy_onvif/cmd/onvif_helper_command.dart:28:14) #14 OnvifGetDeviceInformationResponseDeviceManagementCommand.run (package:easy_onvif/cmd/onvif_device_management_command.dart:68:5) #15 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
faithoflifedev commented 1 year ago

Hi @rho558 , this is exactly what I needed.

It looks like your onvif device is really lax on following the documented standard. It's not responding with the required fields for the given request. I've updated the code to accommodate this. A new version easy_onvif: 2.0.13+16 has just been published.