Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wmhseir3 opened this issue Oct 22, 2021 · 10 comments

Comments

@wmhseir3
Copy link

hi, I have recently obtained one onvif nvt which is working smoothly using the top download onvif app from Google play.
However, this new nvt can not even run the "await onvif.initialize();" The DioError messages captured are as followings. I am suspecting the Dio plugin may have compatibility issues as with easyonvif. As issue #3/4 and this issue are all related with it. Can you please change the Dio to else one which might help solving these issues?

E/flutter (13446): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: DioError [DioErrorType.other]: HttpException: Connection closed before full header was received, uri = http://192.168.1.106:8000/onvif/device_service
E/flutter (13446): #0 DioMixin.assureDioError (package:dio/src/dio_mixin.dart:819:20)
E/flutter (13446): #1 DioMixin._dispatchRequest (package:dio/src/dio_mixin.dart:678:13)
E/flutter (13446):
E/flutter (13446): #2 DioMixin.fetch.. (package:dio/src/dio_mixin.dart)
E/flutter (13446):
E/flutter (13446):
E/flutter (13446): #0 Soap.send (package:easy_onvif/src/soap.dart:34:7)
E/flutter (13446):
E/flutter (13446): #1 Soap.retrieveEnvlope (package:easy_onvif/src/soap.dart:43:26)
E/flutter (13446):
E/flutter (13446): #2 DeviceManagement.getSystemDateAndTime (package:easy_onvif/src/deviceManagement.dart:145:22)
E/flutter (13446):
E/flutter (13446): #3 Onvif.initialize (package:easy_onvif/src/onvif.dart:33:22)
E/flutter (13446):
E/flutter (13446): #4 _MyHomePageState._initialize (package:testeasyonvif/main.dart:79:5)

@faithoflifedev
Copy link
Owner

@wmhseir3, the latest PR #7 is an attempt to address this issue. I found the following info that speaks broadly to the issue:

Though I don't think either necessarily applies here. I did see that I was creating a new Dio instance for every SOAP request. With the latest changes, that is no longer the case. Let me know if this resolves things for you.

@faithoflifedev
Copy link
Owner

Btw, easy_onvif 0.0.11 has now been published.

@wmhseir3
Copy link
Author

hi, the 0.0.11 won't get through with this issue the same DioError appears as followings:
E/flutter (16871): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: DioError [DioErrorType.other]: HttpException: Connection closed before full header was received, uri = http://192.168.1.102:8000/onvif/device_service
E/flutter (16871): #0 DioMixin.assureDioError (package:dio/src/dio_mixin.dart:819:20)
E/flutter (16871): #1 DioMixin._dispatchRequest (package:dio/src/dio_mixin.dart:678:13)
E/flutter (16871):
E/flutter (16871): #2 DioMixin.fetch.. (package:dio/src/dio_mixin.dart)
E/flutter (16871):
E/flutter (16871):
E/flutter (16871): #0 Soap.send (package:easy_onvif/src/soap.dart:34:7)
E/flutter (16871):
E/flutter (16871): #1 Soap.retrieveEnvlope (package:easy_onvif/src/soap.dart:43:26)
E/flutter (16871):
E/flutter (16871): #2 DeviceManagement.getSystemDateAndTime (package:easy_onvif/src/deviceManagement.dart:145:22)
E/flutter (16871):
E/flutter (16871): #3 Onvif.initialize (package:easy_onvif/src/onvif.dart:33:22)

I tried to add the timeout lines as followings but still the same. Any other workaround?
response = await dio.post(url,
data: requestData,
options: Options(
sendTimeout: 2000,
receiveTimeout: 0,
headers: {
Headers.contentTypeHeader: 'text/xml; charset=utf-8',
Headers.contentLengthHeader: requestData.length
}));

@faithoflifedev
Copy link
Owner

@wmhseir3, I think in this case I'd need a minimal code sample to try to replicate the issue. From what I've read about the problem it may be related to the size of the SOAP response. Without being able to replicate this any further changes I make are purely guess work. Any chance you can provide a small sample of your code?

@wmhseir3
Copy link
Author

hi, just got your reply. My sample code is simple. I just used the flutter new project as in the Android Studio. And add changes with the following codes. This issue is just occured with the "await onvif.initialize();" line. Can you please send me an email ([email protected]) privately. I can then advise how you can reproduce the issue remotely in your end easily. Thanks.

@OverRide
void initState() {
super.initState();
_initialize();
}

_initialize() async {
// final config = loadYaml(File('assets/config.yaml').readAsStringSync());
var onvif = Onvif(
// host: '192.168.1.102:8000',
host: '192.168.1.103:2020',
username: 'admin',
password: 'aa888888');
//initiate connection
await onvif.initialize();
}

@faithoflifedev
Copy link
Owner

@wmhseir3 , thanks for this. I created a flutter app that connects to me to my main test device and everything worked fine. I then changed to connect to an alternate device and I'm starting to see some errors. So far, not the same as you provided, but I see this a progress :-)

@wmhseir3
Copy link
Author

hi, like to see your progress next. Let me know, if you are available to see my test device.

@faithoflifedev

This comment has been minimized.

@faithoflifedev
Copy link
Owner

Please see my recent comment at #3

@wmhseir3
Copy link
Author

I tried 0.12.0 with the flutter_model example. It's still getting the HttpException: Connection closed before full header was received" with the new 2nd nvt. I would like to offer you the steps for you to test with this nvt remotely in your end. Can you please send email to me @[email protected]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants