当前位置: 首页 > 知识库问答 >
问题:

Android设备上的Apollo网络错误(React Native)

郎曜文
2023-03-14

所以我在玩Expo+React Native+yoga graphql server+Apollo Client,通过查询获取数据在浏览器中工作,当我从Expo点击“在浏览器中运行”时,但如果我试图在android模拟器/QR code上从真实的手机上运行该应用程序,它会引发网络错误。附言。我在github上阅读了类似的帖子和问题,所以我设法使graphqlendpoint可以通过nat和No-IP从“外部”访问。(所以这不是localhost问题)。以下是在console.log(error)中引发的错误:

网络错误:网络html" target="_blank">请求失败
*http://192.168.1.55:19001/node_modules/expo/appentry.bundle?platform=android&dev=true&minify=false&hot=false:159227:30 in apolloerror
-node_modules/@apollo/client/apollo-client.cjs.js:681:35 in JS:5083:24 in-node_modules/@apollo/client/apollo-client.cjs.js:5235:22 in useDeepMemo
-node_modules/@apollo/client/apollo-client.cjs:5258:4 in useBaseEquery
*http://192.168.1.55:19001/node_modules/expo/appentry.bundle?platform=android&dev=true&minify=false&hot=false:157867:42在renderWithHooks中-node_modules/react-native/libraries/renderer/implementations/reactnativeRenderer-dev.js:12842:6在updateFunctionComponent-node_modules/react-native/libraries/rend中ERER/implementations/reactnativerEnderer-dev.js:20459:25在BeginWork$$1-node_modules/react-native/libraries/renderer/implementations/reactnativerEnderer-dev.js:19370:24在performUnitWork
-node_modules/react-native/libraries/rementration/reactnativerEnderer-dev.js:19347:39在]:renderroot-node_modules/react-native/libraries/renderer/implementations/reactnativeRenderer-dev.js:18709:28 in runRootCallback*[本机代码]:null in runrootcallback-node_modules/react-native/libraries/renderer/implementations/reactnativeRenderer-dev.js:5642:32 in dev.js:5638:22在flushsynccallbackqueueimpl-node_modules/react-native/l中ibraries/renderer/implementations/reactNativerEnderer-dev.js:5627:28 in flushsyncallbackqueue-node_modules/react-native/libraries/renderer/implementations/reactNativerEnderer-dev.js:18556:30 in scheduleupdateonfiber-node_modules/react-native/libraries/renderer/implements/reactNativerEnderer-dev.js:11484:17 in_0.error-node_modules/zen-observable/lib/observable.js:139:8 in notifySubscription*http://192.168.1.55:19001/node_modules/expo/appentry.bundle?platform=android&dev=true&minify=false&hot=false:165854:23 in onnotify-node_modules/zen-observable/lib/observable.js:239:11 in error*[本机代码]:null in forEach/expo/appentry.bundle?platform=android&dev=true&minify=false&hot=false:159700:31 in onError-node_modules/@apollo/client/apollo-client.cjs.js:2424:20 in invoke-node_modules/@apollo/client/apollo-client.cjs.js:2785:24 in info.listeners.forEach$argument_0*[native code]:null in foreach-node_modules/@apollo/client/apollo-client.cnjs.js:2781:34 in queries.forEach$argument_0*[native code]:2781:8 in querymanager.p://192.168.1.55:19001/node_modules/expo/appentry.bundle?platform=android&dev=true&minify=false&hot=false:161498:45 in-node_modules/promise/setimmediate/core.js:37:14 in trycallone-node_modules/promise/setimmediate/core.js:123:25 in espass-node_modules/react-native/libraries/core/timers/jstimers.js:458:30 in callImmediates*[本机代码]:null in callimmediates-node_modules/react-n在__callimmediates-node_modules/react-native/libraries/batchedbridge/messagequeue.js:143:6在__guard$argument_0-node_modules/react-native/libraries/batchedbridge/messagequeue.js:384:10在__guard-nodeles/react-native/libraries/batchedbridge/messagequeue.js:142:17在__guard

我做错了什么?-(

共有1个答案

纪辰沛
2023-03-14

因此,如果您想让graphqlendpoint可以从“外部世界”访问,您必须在https下进行,因为expo server运行在一个安全的连接上,它将拒绝从一个不安全的连接加载数据。我一直试图在graphql-yoga服务器上实现ssl,但最终将graphqlendpoint部署到heroku或prisma cloud上要快得多,在那里https是开箱即用的!不过,上面显示的堆栈错误与Apollo没有获取数据无关,因为它现在仍然弹出!我希望这能帮助其他人腾出一些时间!

 类似资料:
  • 状态{statuscode=network_error,resolution=null} 任何形式的帮助都将受到高度赞赏。

  • 我希望能够在我的网络上发现Android设备,并可能检索一些关于它们的设备信息。这对于苹果设备来说非常容易,因为它们运行Bonjour服务。然而,我似乎找不到任何类似的服务运行在Android上。 这必须在不修改Android设备,安装某些服务或打开某些端口的情况下工作。它旨在与vanilla Android设备配合使用,就像Bonjour帮助您找到vanilla Apple设备一样。即使能够验证

  • Linux提供了许多虚拟设备,这些虚拟设备有助于构建复杂的网络拓扑,满足各种网络需求。 网桥(bridge) 网桥是一个二层设备,工作在链路层,主要是根据MAC学习来转发数据到不同的port。 # 创建网桥 brctl addbr br0 # 添加设备到网桥 brctl addif br0 eth1 # 查询网桥mac表 brctl showmacs br0 veth veth pair是一对虚拟

  • 问题内容: 这是我现在正在使用我的Android应用程序处理的问题。程序在模拟器上运行正常,没有任何错误,但在运行相同操作系统的真实设备上却出现了错误。 我有一个应用程序小部件更新服务,可以更新我的小部件。此服务检查窗口小部件是否在屏幕上,否则不进行更新过程。在模拟器上工作正常。 每次必须在OnReceive方法中更新窗口小部件时,我都会在字符串变量check_intent中捕获该意图,该变量告诉

  • 我试图发现我的设备连接到的WiFi网络上的所有设备。这是普通的Java,不是Android。我需要搜索每个设备,看看它是否有一个特定的端口打开。我将通过连接到我发现的第一个符合此条件的设备,所以我需要它的IP地址。我基本上是在尝试编写以下代码:

  • 我目前正在开发一个项目,我需要为应用程序录制VOIP通话,例如(Whatsapp和其他使用VOIP通话的应用程序) 我已经尝试了下面的代码来触发事件,当whatsapp调用时,所以我同时启动了录音机,但这是问题所在 当录音开始时,同时WhatsApp通话,然后接收器无法收听我的声音,但我可以听到他的声音,音频只录制了我的声音-基本上,录音开始时,它使用与WhatsApp相同的音频源,所以Whats