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



所以我在玩Expo+Rreact Native+yoga graphql服务器+Apollo客户端,通过查询获取数据可以在浏览器中工作,当我在Expo中点击"在浏览器中运行"时,但如果我试图在android模拟器上运行应用程序,就会引发网络错误/qr代码。附言:我在github上读到了类似的帖子和问题,所以我设法通过nat和无ip从"外部"访问了我的graphql端点。(所以这不是本地主机的问题)。这是控制台中抛出的错误。log(错误):

网络错误:网络请求失败
*http://192.168.1.55:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:ApoloError中的159227:30
-ObservableQuery.protype.getCurrentResult中的node_modules/@apollo/client/apollo-cjs.js:681:35-useDeepMemo中的node_modules/@apolo/client/apolo-client.cjs.js:5235:22
-useBaseQuery中的node_modules/@apollo/client/apolo-client.cjs:5258:4
*http://192.168.1.55:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:157867:42 in-node_modules/areact native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:10696:27 in renderWithHooks-node_modules/Areact native/librarys/Renderer/aImplementations/ReactNativeRenderrer-dev.js:12842:6 in updateFunctionComponent-beginWork$$1中的node_modules/rect native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:220459:25-performUnitOfWork中的node_modules/rectNativeLibraries/ReRenderer/applementations/ReactNativeRendeler-dev.js:119370:24
-中workLoopSync
-node_modules/areact native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:18997:22在renderRoot中
*[本机代码]:在renderRoot中为null-runRootCallback中的node_modules/areact native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:18709:28*[本机代码]:runRootCallback中为null-runWithPriority$argument_1中的node_modules/areact native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:5642:32-node_modules/scheduller/cjs/scheduler.development.js:643:23在不稳定的runWithPriority中-flushSyncCallbackQueueImpl中的node_modules/areact native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:5638:22-flushSyncCallbackQueue中的node_modules/areact native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:5627:28-scheduleUpdateOnFiber-dispatchAction中的node_modules/areact native/librarys/Renderer/aimplementations/RectNativeRenderer-dev.js:1184:17*[本地代码]:dispatchAction中为null-obsQuery.subscribe$argument_0.error中的node_modules/@apolo/client/apolo-client.cjs.js:5174:26-notifySubscription中的node_modules/zen observable/lib/observable.js:139:8*http://192.168.1.55:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:1654:23在onNotify中-node_modules/zen observable/lib/observable.js:239:11错误*[本地代码]:forEach中为null-iterateObserversSafely中的node_modules/@apolo/client/apolo-client.cjs.js:956:4*http://192.168.1.55:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:159700:31在onError中-invoke中的node_modules/@apolo/client/apolo-client.cjs.js:22424:20-node_modules/@apolo/client/apolo-client.cjs.js:2785:24 in info.elistener.forEach$argument_0*[本地代码]:forEach中为null-查询中的node_modules/@apolo/client/apolo-client.cjs.js:2783:34。forEach$argument_0*[本地代码]:forEach中为null-QueryManager.prototype.broadcastQueries中的node_modules/@apolo/client/apolo-client.cjs.js:2781:8*http://192.168.1.55:19001/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false:161498:45英寸-node_modules/prowere/setimmediate/core.js:37:14在tryCallOne中-setimmediate$argument_0中的node_modules/promee/setimmediate/core.js:123:25-_callTimer中的node_modules/areact native/Libraries/Core/Timers/JSTimers.js:146:14-_callImmediatesPass中的node_modules/areact native/Libraries/Core/Timers/JSTimers.js:194:17-callImmediates中的node_modules/areact native/Libraries/Core/Timers/JSTimers.js:458:30*[本机代码]:callImmediates中为null-__callImmediates中的node_modules/areact native/Libraries/BatchedBridge/MessageQueue.js:407:6-__guard$argument_0中的node_modules/areact native/Libraries/BatchedBridge/MessageQueue.js:143:6-__guard中的node_modules/areact native/Libraries/BatchedBridge/MessageQueue.js:384:10-__guard$argument_0中的node_modules/areact native/Libraries/BatchedBridge/MessageQueue.js:142:17*[本机代码]:flushdQueue中为null*[本机代码]:callFunctionReturnFlushedQueue 中为null

我做错了什么?:-(

所以,如果你想让你的graphql端点从"外部世界"访问,你必须在https下进行,因为expo服务器运行在一个安全的连接上,它会拒绝从一个不安全的连接加载数据。我一直在尝试在graphql yoga服务器上实现ssl,但最终将graphql端点部署到heroku或prisma云会更快,因为那里提供了开箱即用的https!不过,我上面显示的堆栈错误与Apollo没有获取数据无关,因为即使现在它仍然会弹出!我希望这能帮助其他人腾出一些时间!

最新更新