/rnFailover

This repo demonstrates a simple client-side failover with react-native app as frontend and two express servers as backend

Primary LanguageObjective-C

Purpose

This repository demonstrates a simple mechanism for client-side fail-over technique.

Idea

  1. We will start two back-end server built as a standalone app by expressjs
  2. Then we will try to hit our servers from our react-native frontend app

Outcome

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.

Requirement

  • node LTS
  • yarn
  • react-native cli
  • dev environment for android or ios specific

Setup

$ 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

Other command available

backend

$ yarn start #bring up both server
$ yarn run server1 #bring up server1