diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js index 03619f60c3ce27..1301c47ecfa768 100644 --- a/Libraries/Utilities/HMRClient.js +++ b/Libraries/Utilities/HMRClient.js @@ -40,18 +40,36 @@ const HMRClient = { const activeWS = new WebSocket(wsUrl); activeWS.onerror = (e) => { - throw new Error( + let error = ( `Hot loading isn't working because it cannot connect to the 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 +Try the following to fix the issue: +- Ensure that the packager server is running and available on the same network` + ); + + if (Platform.OS === 'ios') { + error += ( +` +- Ensure that the Packager server URL is correctly set in AppDelegate` + ); + } else { + error += ( +` +- Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run 'adb devices' to see a list of connected devices +- If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device +- If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081` + ); + } + + error += ( +` URL: ${host}:${port} Error: ${e.message}` ); + + throw new Error(error); }; activeWS.onmessage = ({data}) => { // Moving to top gives errors due to NativeModules not being initialized diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java index d8d802320837b6..78b570e6f3c614 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java @@ -194,12 +194,12 @@ public void onFailure(Request request, IOException e) { StringBuilder sb = new StringBuilder(); sb.append("Could not connect to development server.\n\n") - .append("URL: ").append(request.urlString()).append("\n\n") .append("Try the following to fix the issue:\n") .append("\u2022 Ensure that the packager server is running\n") .append("\u2022 Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run 'adb devices' to see a list of connected devices\n") .append("\u2022 If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device\n") - .append("\u2022 If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081"); + .append("\u2022 If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081\n\n") + .append("URL: ").append(request.urlString()); callback.onFailure(new DebugServerException(sb.toString())); }