I am using DIO package here. My problem is I cannot clearly understand what "connectTimeout" parameter is in dio options. First I thought it is the time that if there is no internet connection, it will try to connect to the API within the specified time.
Docs say the following:
/// Timeout in milliseconds for opening url. /// [Dio] will throw the [DioError] with [DioErrorType.CONNECT_TIMEOUT] type /// when time out.
I tested my assumption by calling the script below with internet disabled
Dio dio = new Dio();
Response response;
dio.options.connectTimeout = 50000;
dio.options.receiveTimeout = 30000;
dio.options.sendTimeout = 30000;
response = await dio
.get(GeneralStringUtil.someGetAPI);
I instantly got the following as an exception in my log:
DioError [DioErrorType.DEFAULT]: SocketException: Failed host lookup: xyz.com
So my assumption is wrong. What is this "connectTimeout" parameter?
you set a limit of 50000 miliSeconds so dio will trying the http call for 50000 miliSeconds if it will fail to connect to the server during this time period them it will show the exception, the more you increase the time longer the dio will try to connect