react-native-node: Running example code results in network error at RN fetch()

First of all: Thanks for this project!

I am checking out the /example code and when running as described in the README and without modifications I get following error:

TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (fetch.js:441)
    at XMLHttpRequest.dispatchEvent (event-target.js:172)
    at XMLHttpRequest.setReadyState (XMLHttpRequest.js:546)
    at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:381)
    at XMLHttpRequest.js:485
    at RCTDeviceEventEmitter.emit (EventEmitter.js:181)
    at MessageQueue.__callFunction (MessageQueue.js:260)
    at MessageQueue.js:101
    at MessageQueue.__guard (MessageQueue.js:228)
    at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:100)

I will look into this further, but maybe there is something obvious I am overlooking…

(Versions: yarn 0.24.6, npm 4.2.0, ubuntu 16.04, (local) node: 7.10.1)

PS I will try again with downgraded node on ubuntu system

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 1
  • Comments: 21 (4 by maintainers)

Most upvoted comments

Hi @staltz

I got it working by refactoring to J2V8:

Steps:

  • clone J2V8
  • python build.py --interfactive (using the not-yet-merged build improvement PR)
  • import j2v8-release.aar in react-native-node (8.7 MB, Node 7.9.0 for me, soon 8.1.2)
  • in react-native-node compile project(':j2v8-release')
  • node application is at android/app/src/main/assets (will refactor this to be ./Background)
  • remove any non-standard RN stuff from the gradle projects

Then RNNodeService.java like this:

(PS You don’t need a V8Thread. A normal one will do)

For some reason I had to redefine RNNodeModule.start to have no parameters when called with no parameters from RN, otherwise I ended up with error NativeArgumentsParseException got 0 arguments expected 1. Will look into this later.

I now know much more on J2V8 now (see Viable options to running NodeJS on Android (Aug 2017)) and am convinced that both react-native-node and node-on-android would benefit by using this as a basis to build on further. It would not add any overhead in the way the project is working now, and gives some powerful options in e.g. communicating between RN and Node.

I will keep you posted on more findings.

This is current status: https://github.com/eclipsesource/J2V8/issues/332 May be solved when J2V8 is ready to build Node 8.4.0 (which is almost)