0

I need to check if internet accessible from the mobile or not in order to show a different view in my app.

My app is in react-native and I am using the plugin react-native-netinfo for this. but this plugin pings google for checking the connectivity. As Google is blocked in china I am getting is not connected though connected to internet. Is there any other site instead of http://google.com/generate_204

I can set the site name using the options provided:

NetInfo.configure({
            reachabilityUrl: 'http://google.com/generate_204',
            reachabilityTest: async response => response.status === 200,
            reachabilityLongTimeout: 60 * 1000, // 60s
            reachabilityShortTimeout: 50 * 1000, // 5s
            reachabilityRequestTimeout: 15 * 1000, // 15s
        });

I have tried using GitHub.com that's also now blocked in China. Is there any reliable site that I can use for long term as well specially for China?

Note: can check whether site usable in china or not using: http://www.chinafirewalltest.com

praveen seela
  • 538
  • 11
  • 24
  • why does your app need the internet? why not check if the services the app needs are accessible? – DevWithZachary Jul 13 '21 at 08:36
  • I have mentioned it in the first, that I need to display a new view if app is offline. so I need constantly look for internet connectivity. if there is any public reliable site it will be helpful else exposing a public endpoint from my api's is risky. – praveen seela Jul 13 '21 at 08:40

1 Answers1

0

You can check www.baidu.com which is the search engine in China.

But this is not "Internet reachable", it is "site reachable". Even if www.baidu.com is reachable, it does not mean your target site is reachable.

AIMIN PAN
  • 1,563
  • 1
  • 9
  • 13
  • if we reach directly Baidu.com it will big html in return. if we are checking for more no of times it may treat as a bot attack and block. So, having some service which simply return status 204 is the best one to use, does Baidu has a generate_204 like google? – praveen seela Jul 13 '21 at 08:45