This repository demonstrates a simple mechanism for client-side fail-over technique.
- We will start two back-end server built as a standalone app by expressjs
- Then we will try to hit our servers from our react-native frontend app
By default, our app will fail on first server due to timeout and will fetch data from our second server. Hence, Fail-over is complete.
Second fetch does not have timeout and fail-over.
- node LTS
- yarn
- react-native cli
- dev environment for android or ios specific
$ git clone https://github.com/Sadathossain/rnFailover.git
$ cd rnFailover/backend
$ yarn install
$ yarn run server2
# open another terminal with same directory
$ cd ../frontend
$ yarn install
# forward second server port through adb
$ adb reverse tcp:3001 tcp:3001
$ react-native run-android
$ yarn start #bring up both server
$ yarn run server1 #bring up server1