dart-lang / dart-lang/http

HandshakeException: Connection terminated during handshake

Open
#443 0 comments 0 reactions 0 assignees View on GitHub
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
![image](https://user-images.githubusercontent.com/39715233/87593296-dd71fc00-c6b0-11ea-892c-76c0a5938b51.png)

This usually happens too:
![image](https://user-images.githubusercontent.com/39715233/87593323-e793fa80-c6b0-11ea-9c6b-722bc10508c6.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.