HandshakeException: Connection terminated during handshake
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 419
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 8
Description
I get the following exception when I make http requests, what could be happening? The exception itself occurs when making get requests.
In addition to the http package I use httpinterceptor, but origin marks in an http plugin file
Note: this does not happen all the time, it rarely occurs

This usually happens too:

The interceptior corresponds to this code:
```
import 'dart:async';
import 'package:http_interceptor/http_interceptor.dart';
class Interceptor implements InterceptorContract {
@override
Future interceptRequest({RequestData data}) async {
if (_session != null) {
data.headers['authorization'] = 'TOKEN';
data.headers['content-type'] = 'application/json';
}
return data;
}
@override
Future interceptResponse({ResponseData data}) async {
return data;
}
}
```
And itself the http request corresponds to this code
```
import 'package:http/http.dart' as http;
import 'package:http_interceptor/http_client_with_interceptor.dart';
import 'package:larvia/src/interceptor/interceptor.dart';
class ApiHelper {
HttpClientWithInterceptor client = HttpClientWithInterceptor.build(interceptors: [
Interceptor(),
]);
Future get(String url, {Map params}) async {
final Uri uri = Uri(scheme: 'https', host: 'domain', path: url, queryParameters: params);
http.Response response = await client.get(uri);
return response;
}
}
```
Contributor guide
Research direction
Start by reviewing the provided Interceptor and ApiHelper code, then reproduce the intermittent HTTPS GET failure with the http and http_interceptor packages. Compare the exception and accompanying errors across successful and failed requests; done would require a reliable diagnosis and a confirmed package-level fix or clear evidence that the problem is outside this repository.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100