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.
32 stars 18 forks source link

[GetProfiles] DioError [DioErrorType.other]: HttpException: Connection closed before full header was received. #10

Closed Cu-Toof closed 2 years ago

Cu-Toof commented 2 years ago

I use easy_onvif v0.0.15 to connect to a camera IP. Getting the camera's information is successful but getting profiles is not. Could you provide me with some solution for this issue? thanks I receive some answers: requestData is too large. Could you provide me with some solution for reducing requestData size? thanks

Exception: DioError [DioErrorType.other]: HttpException: Connection closed before full header was received, uri = [http://14.241.168.136/onvif/media_service]()
        Source stack:
#0      DioMixin.fetch
package:dio/src/dio_mixin.dart:479
#1      DioMixin.request
package:dio/src/dio_mixin.dart:474
#2      DioMixin.post
package:dio/src/dio_mixin.dart:97
#3      Soap.send
package:camera_control/…/src/soap.dart:18
#4      Soap.retrieveEnvlope
package:camera_control/…/src/soap.dart:52
#5      Media.getProfiles
package:camera_control/…/src/media.dart:41
#6      _MyHomePageState._initialize
package:camera_control/main.dart:94
faithoflifedev commented 2 years ago

Hello @Cu-Toof ,

I found the following regarding the "Connection closed..." issue - https://stackoverflow.com/questions/55879550/how-to-fix-httpexception-connection-closed-before-full-header-was-received - a number of the solutions are related to the underlying network and there is no code change that I can make to resolve them.

If the problem is related to the requestData then I'm not sure that there is any change that I can make. Onvif is an XML based protocol and XML is very verbose.

I would more expect that applications would have a problem with the response data. I have yet to find a decent XML parser that supports namespaces in Dart. My work-around was to convert the Onvif XML response to JSON and then to Dart objects. This is very memory inefficient for large responses, but until a better XML parser comes around ...

The only partial solution I can offer right now is to add a section to the README asking people to list Onvif device models that they know the package works with and those where it doesn't. That way some people will know in advance if their Onvif device is supported.

faithoflifedev commented 2 years ago

Hello @Cu-Toof ,

I published a new version today - 1.0.0-dev.2 - you can give it a try and see if it solves your issue.

faithoflifedev commented 2 years ago

Hello @Cu-Toof ,

I was able to identify a bug that was causing this issue with some devices. The new v1.0.2 resolves the issue.

faithoflifedev commented 1 year ago

https://github.com/faithoflifedev/easy_onvif/issues/32 gives more detail about this issue.