【问题标题】:i am going to run localhost .net api in flutter to get data from it but i got a lot of errors我将在 Flutter 中运行 localhost .net api 以从中获取数据,但我遇到了很多错误
【发布时间】:2022-07-06 00:16:43
【问题描述】:

我打算快速运行 localhost .net API 以从中获取数据,但我遇到了很多错误。为什么.net API 是本地托管的。我想运行本地 Web API,但不想将其托管在实时服务器上。

这里是代码

static Future fectchCordinates() async
{
    HttpClient client = new HttpClient();
    client.badCertificateCallback = ((X509Certificate cert, String host, int port) => true);
    var studentUrl =Uri.parse('https://10.0.2.2:44363/address-lookup?address=house%20no%20122%20');
    //Uri.parse(studentUrl),
    print(studentUrl);
    http.Response response=await http.get(studentUrl,headers: {"Accept": "application/json"});
    print(response.body);
    return response;
} 

E/flutter (8373): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] 未处理异常:HandshakeException:客户端握手错误(操作系统错误:
E/flutter (8373): CERTIFICATE_VERIFY_FAILED: 无法获得本地颁发者证书(handshake.cc:393))
E/flutter (8373): #0 _SecureFilterImpl._handshake (dart:io-patch/secure_socket_patch.dart:99:46)
E/flutter (8373): #1 _SecureFilterImpl.handshake (dart:io-patch/secure_socket_patch.dart:142:25)
E/flutter (8373): #2 _RawSecureSocket._secureHandshake (dart:io/secure_socket.dart:911:54)
E/flutter (8373): #3 _RawSecureSocket._tryFilter (dart:io/secure_socket.dart:1040:19)
电子/颤振(8373):
E/颤动(8373):

【问题讨论】:

  • TLS 失败,发生在发送 HTTP 请求之前。客户端和服务器之间的加密模式、TLS 模式或证书不兼容。您正在使用本地主机。你用的是什么端口号?该端口可能被阻止或被另一个应用程序使用。可能是IP地址错误。

标签: c# asp.net flutter api


【解决方案1】:

尝试使用 http 调用您的本地 api 并将 house%20... 替换为正确的端点: http://10.0.2.2:44363/address-lookup?address=house"YourCorrectEndPoint"

or try to use this link

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-19
    • 1970-01-01
    • 2020-03-26
    • 2015-02-02
    相关资源
    最近更新 更多