Comments (13)
每发一次请求,Client Address的端口值都会变。
我使用 iOS原生网络请求框架 Alamofire进行网络请求时,Client Address的端口值不会变,HTTPS连接会进行持久连接,Kept Alive 值为true,TLS HandShake 值为 -
能帮我看一下,在dio中如何能 保持持久连接么?每次请求不需要重新进行 TLS 握手。
from dio.
I also encountered the same problem
from dio.
same here
from dio.
how to fix
from dio.
is this a new issue?
from dio.
I solve this by the following code:
HttpClient createMyHttpClient() {
return HttpClient()..idleTimeout = const Duration(seconds: 300);
}
_dio.httpClientAdapter =
IOHttpClientAdapter(createHttpClient: createMyHttpClient);
from dio.
I solve this by the following code: HttpClient createMyHttpClient() { return HttpClient()..idleTimeout = const Duration(seconds: 300); } _dio.httpClientAdapter = IOHttpClientAdapter(createHttpClient: createMyHttpClient);
thanks, but i don't know if it really works, how can i test it ?
from dio.
I solve this by the following code: HttpClient createMyHttpClient() { return HttpClient()..idleTimeout = const Duration(seconds: 300); } _dio.httpClientAdapter = IOHttpClientAdapter(createHttpClient: createMyHttpClient);
thanks, but i don't know if it really works, how can i test it ?
use flutter devtools --> network tab, check the connection establish time.
from dio.
idleTimeout
corresponds to the alive time of the client. If your client got released in a short time, please consider increasing the configuration. It's also recommended to test with the dart:io:HttpClient
and package:http
.
from dio.
This is why keep-alive not working. The default idleTimeout
for underlying package:http
is 15 seconds. However, don't know why dio
set it to 3 seconds. According to package:http
documentation. The non-active connection in pool will be closed by min(idleTimeout, keep-alive timeout)
.
dio/dio/lib/src/adapters/io_adapter.dart
Line 242 in cca8439
from dio.
Dio 10 requests with no sleep in between
Dio 10 requests with 4s sleep in between
dart:http
10 requests with 4s sleep in between
from dio.
The HttpClient.idleTimeout
of 3 seconds has already been removed on the 6.0.0
branch. The behavior will not be changed for 5.x
since this is in some ways a breaking change.
from dio.
In order to get rid of the default 3 seconds timeout, either create a new HttpClient
with a new timeout using createHttpClient
or set the timeout using onHttpClientCreate
(deprecated).
from dio.
Related Issues (20)
- Prompt for not simple requests on Web HOT 2
- DioException response.data is null HOT 1
- [native_dio_adapter] Windows build breaks when adding package HOT 1
- DioException (DioException [connection error]: The connection errored: Connection reset by peer This indicates an error which most likely cannot be solved by the library. HOT 3
- Add privacy manifest file for iOS HOT 1
- incorrect formatting when parsing `multipart` form data using `FormData.fromMap()` causes `NullReferenceException` in .NET backend HOT 2
- I can't return my own errors class in onError interceptor HOT 1
- RFC - Custom DNS Resolver HOT 2
- I can't use MediaType when I create MultipartFile HOT 1
- Update for wasm HOT 1
- Implement automatic redirects for requests regardless of the `HttpClient` HOT 1
- Migrating browser_adapter.dart for WASM HOT 2
- Remove the message 'The request was manually cancelled by the user.' for canceltoken.cancel() HOT 1
- Target of URI doesn't exist: 'package:dio/adapter.dart'. Try creating the file referenced by the URI, or try using a URI for a file that does exist. HOT 1
- Dio (HttpClient) cannot set a self-signed trust certificate HOT 4
- [Proposal] Improve toString() of InterceptorState
- Cronet exception: m.ms: Exception in CronetUrlRequest: net::ERR_CONNECTION_CLOSED, ErrorCode=5 HOT 2
- 503 Status Code With the Https base URL HOT 1
- DIo not working while adding extras in requestOptions with path in Dio singleton HOT 3
- Type Casting Error: '_Map<String, dynamic>' is not a Subtype of 'T?' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dio.