gpt4 book ai didi

ios - SocketException (SocketException : Failed host lookup: 'test' (OS Error: nodename nor servname provided, or not known, errno = 8))

转载 作者:行者123 更新时间:2023-12-03 03:57:39 31 4
gpt4 key购买 nike

我看过别处,每个网站都告诉我这实际上是互联网连接错误......但我知道这不可能是正确的。

我正在使用 Flutter (dart) 为 iOS(在 Mac 上)编程。我在 iOS 模拟器和实际的 iPhone 上都试过这个,我得到了同样的错误。对同一服务器的其他调用工作正常。

Future<Map> createTrip() async {

http.Response response = await http.post(
url,
headers: <String, String>{'authorization': basicAuth},
body: {'user_phone': user_phone, 'locationId1': locationId1, 'locationId2': locationId2},

);
info = jsonDecode(response.body);
sessionID = info['session_id'];
print (info['session_id']);
return info;
}

工作正常。在响应正文中,它包含 session_id,并且 print-screen 证明此变量不为空。

但是这个:
Future<Map> getServerData(sessionID) async {
url = url + sessionID; //. <--- adding sessionID to end of a url-address
http.Response response = await http.get(
url,
headers: <String, String>{'authorization': basicAuth},
);
Map data = jsonDecode(response.body);
return data;
}

不工作。不完全确定为什么。我什至尝试在 info.plist 中允许不安全的数据传输到服务器。

我的理解或期望是,这可能是因为服务器上不存在我请求的 url?这是唯一对我有意义的事情。如果不是,那可能是什么?

Flutter Doctor 结果:
[✓] Flutter (Channel master, v1.14.2-pre.54, on Mac OS X 10.15.2 19C57, locale
en-CA)
• Flutter version 1.14.2-pre.54 at /Users/iosdev/Developer/flutter
• Framework revision da0bfd1c93 (32 hours ago), 2020-01-21 05:59:07 -0500
• Engine revision c15efb9231
• Dart version 2.8.0 (build 2.8.0-dev.3.0 f910a7575f)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/iosdev/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build
1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (2 available)
• Phillip’s iPhone • 52a4fba45a6767b88e4dddd881201205138cac0e • ios • iOS
13.3
• iPhone 11 Pro Max • 2F6FBCBE-CC96-4044-84FA-0DE39E441830 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

• No issues found!

最佳答案

确保您的模拟器或设备上有互联网。通过在模拟器或设备上打开 Internet 浏览器来检查 google.com 是否会成功显示

关于ios - SocketException (SocketException : Failed host lookup: 'test' (OS Error: nodename nor servname provided, or not known, errno = 8)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59866380/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com