ConnectionTimeout无法在Dart中按预期方式工作

时间:2019-12-27 10:38:05

标签: flutter dart

      HttpClient httpClient = new HttpClient();
      httpClient.connectionTimeout = Duration(seconds: 180);
      HttpClientRequest request = await httpClient.postUrl(Uri.parse(url));
      request.headers.set('content-type', 'application/json');
      request.add(utf8.encode(json.encode(params)));
      HttpClientResponse response = await request.close().timeout(const Duration(seconds: 180));
      httpClient.close();

      String chargeSessionEndPoint;
      if (response.statusCode == 200) {
        //Handling Response
      }

从我的服务器获取响应有一个延迟(大约3分钟)。由于我将超时时间设置为3分钟,但仍然超时时间为1分钟。

能帮我一下吗?

使用的http软件包。

0 个答案:

没有答案