【问题标题】:Error while making json api call in flutter在颤振中进行json api调用时出错
【发布时间】:2020-12-26 20:28:52
【问题描述】:

我面临以下错误

Unhandled Exception: SocketException: Insecure socket connections are disallowed by platform: 111.11.111.11

在 Flutter 应用程序中执行以下对服务器的 json api 调用时

var response = await http.post(loginapiUrl, body: data);

我无法为我的网址配置 https://。请给我解决方案

【问题讨论】:

  • 你在本地测试吗?
  • @Khal 不,我不在本地主机上测试
  • 好的,所以我假设您在 c 面板上,您可以从该网站找到如何创建 ssl namecheap.com/support/knowledgebase/article.aspx/9418/33/…
  • @Khal 无论如何都可以使用http://only,因为早些时候这是有效的,现在令我惊讶的是,它不起作用

标签: json api flutter


【解决方案1】:

在访问不安全连接时分别在 Android 和 iOS 中添加网络配置。

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="false">
        <domain includeSubdomains="true">secure.example.com</domain>
    </domain-config>
</network-security-config>

在相应的文件夹中将这些东西添加到 AndroidManifest 中。

有关更多说明,请按此操作。

https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted

【讨论】:

猜你喜欢
  • 2022-01-14
  • 2021-05-13
  • 2023-03-08
  • 2021-06-12
  • 2020-07-23
  • 2021-02-06
  • 2022-06-14
  • 2021-11-03
  • 2021-08-13
相关资源
最近更新 更多