-
Notifications
You must be signed in to change notification settings - Fork 10
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
[BUG] The timeout setting will be invalid when the server does not return data #18
Comments
Hi, thank you for your report, but I don't quite understand the issue you're facing. Please provide what options do you use. Your snippet seems to be related to probe request mode? |
https://github.com/mylisabox/flutter_mjpeg Mjpeg(
isLive: true,
stream: 'http://ruanzheng.com:9430/stream/192.168.1.2?resolution=480P',
fit: BoxFit.fill,
timeout: const Duration(seconds: 5),
httpClient: FetchClient(),
); This mjpeg did not return any data, resulting in the timeout set for the request not taking effect. The mjpeg code has been modified to ensure that it calls the close connection interface. ...
Future<void> dispose() async {
if (_subscription != null) {
await _subscription!.cancel();
_subscription = null;
}
_httpClient.close();
}
...
void updateStream(BuildContext context, ValueNotifier<MemoryImage?> image,
ValueNotifier<List<dynamic>?> errorState) async {
try {
final request = Request("GET", Uri.parse(stream));
request.headers.addAll(headers);
final response = await _httpClient.send(request).timeout(
_timeout); //timeout is to prevent process to hang forever in some case
if (response.statusCode >= 200 && response.statusCode < 300) {
...
} else {
if (context.mounted) {
errorState.value = [
HttpException('Stream returned ${response.statusCode} status'),
StackTrace.current
];
image.value = null;
}
dispose();
}
} catch (error, stack) {
if (context.mounted) {
errorState.value = [error, stack];
image.value = null;
}
dispose();
}
} 3Q |
I've made changes that should incorporate different fix for this issue. |
Fixed it :) |
@heafox I've published this version as 1.1.0 release in Dart Pub. |
It's too late, let me briefly record the problem first
A 5-second timeout was set at the call location
fetch_client.dart
The program will get stuck in this sentence of code 5m return
response = await fetch(request.url.toString(), init);
I added a cancellation callback abort1
The text was updated successfully, but these errors were encountered: