socket.io - 如何修复 Android 9.0 中的套接字 IO 异常?
问题描述
我正在使用 java.net.Socket 进行套接字通信。我已经尝试了 network-security-config.xml 文件的解决方案,该文件允许 localhost 进行套接字通信。
我的代码片段如下:
Socket socket = new Socket("192.168.1.1", "5000");
我的 network-security-config.xml 文件如下:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">http://192.168.1.1:5000</domain>
</domain-config>
我也试过下面的片段
1) Replace <domain includeSubdomains="true">http://192.168.1.1:5000</domain> to <domain includeSubdomains="true">http://localhost:5000</domain>
2) Replace <domain includeSubdomains="true">http://192.168.1.1:5000</domain> to <domain includeSubdomains="true">localhost</domain>
但上述解决方案均无效。可能是我错过了什么。
如果有人有这个问题的经验。请提供解决方案。
谢谢你的帮助。
解决方案
推荐阅读
- excel - Excel - 如何将范围内的所有项目列出到列中?
- unit-testing - 在 Golang 中对 GraphQL 进行单元测试
- javascript - 如何在 vscode 中禁用自动删除行空间?
- python - 如何删除某个字符后的所有内容?
- javascript - 使用 useEffect 钩子在反应功能组件中未使用 .map() 显示的元素
- sql - SQL Server:如何返回最高聚合列
- flask - 在 Flask WTForms 中使用 RadioField 公开其他表单字段
- javascript - 如何过滤排行榜排名
- ubuntu - 如何修复 Fontconfig 警告 - 未知元素错误
- android - 使用视图绑定时布局不居中