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

Increase the idleTimeout to 15 seconds to enhance API response time. #2046

Closed
nahidmk opened this issue Nov 27, 2023 · 5 comments
Closed

Increase the idleTimeout to 15 seconds to enhance API response time. #2046

nahidmk opened this issue Nov 27, 2023 · 5 comments
Labels
i: wontfix This will not be worked on

Comments

@nahidmk
Copy link

nahidmk commented Nov 27, 2023

Request Statement

I want to improve the response time of my API call. When I hit an API using Postman, it takes only 80ms, but the same API takes 250ms in Flutter Dio. Some people suggested me to increase idleTimeout to 15 seconds to improve API response time. I have changed idleTimeout from 3 seconds to 15 seconds, and it actually improves the API response time. So, does it cause any problems to increase idleTimeout to 15 seconds?

Solution Brainstorm

No response

@nahidmk nahidmk added the s: feature This issue indicates a feature request label Nov 27, 2023
@nahidmk nahidmk changed the title ncrease the idleTimeout to 15 seconds to enhance API response time. Increase the idleTimeout to 15 seconds to enhance API response time. Nov 27, 2023
@AlexV525
Copy link
Member

Which idleTimeout?

@nahidmk
Copy link
Author

nahidmk commented Nov 27, 2023

inside the io_adapter

HttpClient _createHttpClient() {
if (createHttpClient != null) {
return createHttpClient!();
}
final client = HttpClient()..idleTimeout = const Duration(seconds: 15);
// ignore: deprecated_member_use, deprecated_member_use_from_same_package
return onHttpClientCreate?.call(client) ?? client;
}

@AlexV525
Copy link
Member

In the code you referenced, you can always specify the idleTimeout when using createHttpClient.

@nahidmk
Copy link
Author

nahidmk commented Nov 27, 2023

"This is the code from Dio's repository located at "lib/src/adapters/io_adapter.dart".

It was initially written as:
final client = HttpClient()..idleTimeout = const Duration(seconds: 3);

I changed it to:
final client = HttpClient()..idleTimeout = const Duration(seconds: 15);

Because of that, I have improved my API response time. So, why didn't the Dio team make this change?"

@AlexV525
Copy link
Member

Improvements are related to use cases. Your use case might fit the 15 seconds idle timeout perfectly, others might not. Generally, changing such configuration will break users code, no one want that happen. Also, as I stated above #2046 (comment), there is no need for you to change the source code. Instead, set the createHttpClient to create your 15 secs timeout client.

Closing as we've already provide such ability.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
@AlexV525 AlexV525 added i: wontfix This will not be worked on and removed s: feature This issue indicates a feature request labels Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i: wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants