【发布时间】:2022-01-16 12:26:24
【问题描述】:
正在构建这个应用程序,我想要实时响应,所以我决定使用 socket.io 和 Nodejs。
在开发过程中,我注意到我的 iPhone 模拟器可以连接到 localhost,但是我的 android 无法连接到 localhost,所以我在一个真正的 Android 设备上进行了测试,但它无法连接。
我接下来要做的是在我的颤振 pubspec.yaml 中安装不同的 socket_io_client 版本,并在我的节点 package.json 中安装不同版本的 socket.io(服务器),但没有解决我的问题
接下来我将 Android 模拟器代理更改为 127.0.0.1 和端口 8000 和 10.0.2.2 以及端口 8000(与我的 nodejs 服务器匹配的端口)但这也不起作用
我做的最后一件事是将我的代码部署到 Heroku 服务器,我想可能无法正确配置我的模拟器以连接本地主机,但令我惊讶的是,Android 模拟器无法连接到我在 Heroku
中运行的服务器Flutter 依赖
socket_io_client: ^2.0.0-beta.4-nullsafety.0
Nodejs (package.json)
{
"name": "prayer_buddy_server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
"engines": {
"node": "14.18.1"
},
"author": "zionnite",
"license": "ISC",
"dependencies": {
"agora-access-token": "^2.0.4",
"express": "^4.17.1",
"nodemon": "^2.0.15",
"socket.io": "^4.4.0",
"uuid": "^8.3.2"
}
}
Flutter Doctor 摘要
Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 18116933e7 (8 weeks ago) • 2021-10-15 10:46:35 -0700
Engine • revision d3ea636dc5
Tools • Dart 2.14.4
apple@APPLEs-MacBook-Air ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.4 20F71 darwin-x64, locale
en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.61.2)
[✓] Connected device (2 available)
! Doctor found issues in 1 category
各位大侠,我该怎么做才能解决这个问题?
【问题讨论】:
标签: android node.js flutter socket.io