Ivo Dimitrov Ivo Dimitrov - 2 years ago 1269
Node.js Question

React-Native. Simulator could not connect to development server

I tried to change ip address that I could test on the device.

After changing lines in AppDelegate.m I did rebuild the application and restarted the server (npm start).

As you can see, the server is visible from the browser, everything works fine, but inside the app says that cannot connect to the server.

jsCodeLocation = [NSURL URLWithString:@""];

After restart project I see:

2016-07-01 13:12:07.949 PropertyFinder[10626:5440580] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
2016-07-01 13:12:09.964 [fatal][tid:main] Could not connect to development server.

Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate


Screenshot: http://dl2.joxi.net/drive/2016/07/01/0001/2707/121491/91/faf405e34d.png

I also tried open this ip in Safari Simulator: http://joxi.ru/RmzQBJKHWkJVOr

I had to use react-native start not npm start

Answer Source

You also need to add the NSAllowsArbitraryLoads key in Info.plist, next to the NSExceptionDomains key, like this:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download