Comments (9)
Getting the same but at the onvif.initialize()
method call. Debugging results in this SOAP response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xs="http://www.w3.org/2000/10/XMLSchema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Sender</soap:Value><soap:Subcode>
<soap:Value>wsse:InvalidSecurity</soap:Value>
</soap:Subcode>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">An error was discovered processing the wsse:Security header.</soap:Text>
</soap:Reason>
<soap:Node>http://www.w3.org/2003/05/soap-envelope/node/ultimateReceiver</soap:Node>
<soap:Role>http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver</soap:Role>
</soap:Fault>
</soap:Body>
</soap:Envelope>
from easy_onvif.
For the Media.getProfiles
the error happens because some json key is not available in the response. In the OP's case, the json['Subcode']
key is not available causing that to be Null
and trying to cast it to Map<String, dynamic>
throws an exception. In my case, I solved the onvif.initialize()
error by extending the Onvif
class and overriding the initialize()
method like this:
@override
Future<void> initialize() async {
try {
await super.initialize();
} catch (e) {
await _initializeOnvif();
}
}
Future<void> _initializeOnvif() async {
// We could do something with the exception to try to determine if it was a "wsse:InvalidSecurity" error.
timeDelta = DateTime.now().toLocal().difference(DateTime.now().toUtc());
final envelope = await Soap.retrieveEnvlope(deviceManagement.uri, secureRequest(SoapRequest.capabilities('All')));
if (envelope.body.capabilitiesResponse == null) throw Exception();
var capabilities = envelope.body.capabilitiesResponse!.capabilities;
_media = Media(onvif: this, uri: capabilities.media.xaddr);
_ptz = Ptz(onvif: this, uri: capabilities.ptz.xaddr);
}
But now, I am getting errors in the getProfiles()
call because other json keys are not available, such as json['VideoAnalyticsConfiguration']
and json['PTZConfiguration']
.
Probably the solution would be to null check for these json keys that are optional in the responses due to the device not having those capabilities or information.
Something like:
videoAnalyticsConfiguration: VideoAnalyticsConfiguration.fromJson(
(json['VideoAnalyticsConfiguration'] ?? Map<String, dynamic>()) as Map<String, dynamic>)
But that code is autogenerated, so maybe doing it by hand or something...
from easy_onvif.
@wmhseir3 , @hsalazarl , confirmed. I should have some time today to dig into this.
from easy_onvif.
easy_onvif 0.0.10 has been published to pub.dev, it included the PR for #5 , let me know if it resolves the issue so I can close this.
from easy_onvif.
@faithoflifedev thank you for addressing these issues. It does fix the main issue with Code, Profile. But there is still problems with the I8nText classs, specifically the two properties are optional, in my case I encountered problems with both:
@JsonKey(name: 'lang')
final String lang;
@JsonKey(name: '\$')
final String text;
In my tests, both could be null sometimes.
Besides that, not sure if you checked the issue with onvif.initialize()
with the GetSystemDateAndTime
failing to return a valid response complaining about the wsse:Security
header. I made a workaround so that I calculate the timeDelta
using the local time like this:
timeDelta = DateTime.now().toLocal().difference(DateTime.now().toUtc());
To be able to wrap next capabilities
request in a secureRequest()
call.
But I guess this is a topic for another issue. Main issue described here is fixed, but there are still some json properties that are optional. That's all. Thank you again.
from easy_onvif.
The 0.0.10 build has still the same issue as following logs when making the "var profs = await onvif.media.getProfiles();", the DioError captured as followings:
E/flutter (10996): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast
E/flutter (10996): #0 _$FaultFromJson (package:easy_onvif/model/fault.g.dart:11:38)
E/flutter (10996): #1 new Fault.fromJson (package:easy_onvif/model/fault.dart:32:56)
E/flutter (10996): #2 _$BodyFromJson (package:easy_onvif/model/body.g.dart:12:19)
E/flutter (10996): #3 new Body.fromJson (package:easy_onvif/model/body.dart:121:55)
E/flutter (10996): #4 _$EnvelopeFromJson (package:easy_onvif/model/envelope.g.dart:10:18)
E/flutter (10996): #5 new Envelope.fromJson (package:easy_onvif/model/envelope.dart:19:7)
E/flutter (10996): #6 Soap.send (package:easy_onvif/src/soap.dart:27:35)
E/flutter (10996):
E/flutter (10996): #7 Soap.retrieveEnvlope (package:easy_onvif/src/soap.dart:43:26)
E/flutter (10996):
E/flutter (10996): #8 Media.getProfiles (package:easy_onvif/src/media.dart:35:22)
Thanks for your prompt solution next.
from easy_onvif.
@wmhseir3, it looks like in this case I did implement the code such that it matches the documented spec. The SOAP 1.2 Fault Spec which is referred to by the Onvif Core Spec (section 5.11.2 SOAP errors) says that the "Reason" field (the field that throws the exception) is required. But it appears that some devices are not supplying the field.
That said, I don't think my code changes to resolve this particular error will solve your problem since the result of the change would be to properly report the fault returned in the SOAP response. In this case the fault code is SOAP-ENV:Receiver with the sub-code is showing ter:ActionNotSupported
So it looks like there is some other issue, maybe related to the SOAP request itself.
from easy_onvif.
@hsalazarl, in my latest code changes (not committed yet)it makes the Detail field of the SOAP fault response optional. I'm hoping that will at least partially resolve the issue that you mention.
from easy_onvif.
@hsalazarl , I'm closing this issue, v0.0.12 resolves it. The problem was that the documented spec for a "fault" (ate least in my interpretation) does not match what is being returned by some devices. The new code does not make any assumptions about the response and will give a descriptive error when throwing an exception.
Additionally, as part of troubleshooting this I did find that there was a namespace issue with the Onvif SOAP envelope being created by the code. I've corrected this as well.
from easy_onvif.
Related Issues (20)
- [2.1.0-dev11] error during onvif.getProfiles() device media1 HOT 2
- [2.1.0-dev11] error during onvif.getStreamUri() device media1 HOT 2
- [2.1.0-dev.14] onvif.mediaSupportLevel HOT 2
- Flutter example application cannot run successfully HOT 2
- RTSP port in the getStreamUri response not correct HOT 3
- camera recording HOT 2
- Is it possible to check if Onvif connect failed? HOT 2
- Onvif Imaging Profile HOT 3
- MulticastProbe with Auth HOT 3
- onvif discovery crash in windows HOT 6
- using CLI for testing causes a crash on onvif probe list-devices HOT 1
- Unable to get preset HOT 26
- new specifications support--thermal interface HOT 2
- How send audio stream to camera ? HOT 3
- Couldn't connect with Ezviz H8c camera HOT 3
- BUG: get-capabilities method is breaking for some cameras HOT 4
- BUG: Camera movement command is not working for some cameras HOT 16
- DioException [receive timeout]: The request HOT 10
- getStreamUri doesn't connect to sub stream of Onvif camera HOT 5
- Actions that require authentication no longer work HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easy_onvif.