React-Native "Could no connect to development server" in createReactContext() - react-native

My Android react-native app is crashing with an ExecutionException.
"Could not connect to development server."
The method that is crashing is ReactInstanceManagerImpl.createReactContext().
But this is not the normal error as this screenshot shows:
Logcat shows me this stacktrace:
Exception in native call from JS
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException:
Could not connect to development server.
at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:860)
at com.facebook.react.ReactInstanceManagerImpl.access$700(ReactInstanceManagerImpl.java:98)
at com.facebook.react.ReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(ReactInstanceManagerImpl.java:194)
...
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException:
at com.facebook.react.common.futures.SimpleSettableFuture.get(SimpleSettableFuture.java:68)
at com.facebook.react.ReactInstanceManagerImpl.createReactContext(ReactInstanceManagerImpl.java:831)
... 9 more
Caused by: java.lang.RuntimeException:
at com.facebook.react.bridge.ReactBridge.loadScriptFromFile(Native Method)
at com.facebook.react.bridge.JSBundleLoader$2.loadScript(JSBundleLoader.java:58)
at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:148)
at com.facebook.react.ReactInstanceManagerImpl$4.call(ReactInstanceManagerImpl.java:851)
...
This suggests that the server has sent the javascript code back to the device and the ReactBridge.loadScriptFromFile() somehow can't handle the bundle.
Points to clarify:
this happens on emulator & device (connected via USB)
this happens on Linux (Mint) & Windows (8.1)
I did run adb reverse tcp:8081 tcp:8081 as per the normal advice
I have run react-native start and the packager/server is running
the device DOES connect to the development server, as this is logged in the packager window
the URL that the device hits does return data, as can be seen if copied into the browser address bar
How is this different from the normal "Could not connect..." message?
Here is a screenshot of what happens when the server is legitimately not running:
The differences include:
no ExecutionException or RuntimeException before the error message
further clarity providing the URL that was called on the server
error comes from DevServerHelper.onFailure()
Logcat shows the stacktrace to be quite different in this normal expected case:
Unable to download JS bundle
com.facebook.react.devsupport.DebugServerException:
Could not connect to development server.
at com.facebook.react.devsupport.DevServerHelper$1.onFailure(DevServerHelper.java:196)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:140)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

This seems to have been caused by not having Windows Build Tools correctly installed. This broke the node-gyp commands required by my project.
Following the steps on the node-gyp page got my machine set up correctly.
After a new build I got this error once, and then it disappeared with the project building and running correctly.

Related

Unable to Switch Appium Context

We have different WebView workflows for our App. I'm able to switch context for the Workflows which has contexts NATIVE_APP, WEBVIEW_com.bluebird.mobile and WEBVIEW_Terrace (3 contexts),
And not able to switch context for the workflows which has only two context NATIVE_APP and WEBVIEW_Terrace. While switching the context I get the following error:
Appium error: An unknown server-side error occurred while processing the command.
Original error: An unknown server-side error occurred while processing the command.
Original error: unknown error: Failed to get sockets matching: #weblayer_devtools_remote_.*14722
(make sure the app has its WebView/WebLayer configured for debugging)
(Driver info: chromedriver=105.0.5195.52 (412c95e518836d8a7d97250d62b29c2ae6a26a85-refs/branch-heads/5195#{#853}), platform=Linux 5.16.7-200.fc35.x86_64 x86_64)
When I look on the internet for the error "make sure the app has its WebView/WebLayer configured for debugging", I see solution to set setWebContentsDebuggingEnabled to true and we already set this configuration because some of the workflows are working.
Please let me know what I need to do here? OR what can I ask my DEV team to fix this.

pa11y failed to Error: Failed to launch chrome

Getting below error while running "pa11y www.google.com"
Welcome to Pa11y
Running Pa11y on URL www.google.com
Error: Failed to launch chrome!
[1127/090329.278232:FATAL:zygote_host_impl_linux.cc(116)] No usable
sandbox! Update your kernel or see
chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md
for more information on developing with the SUID sandbox. If you want
to live dangerously and need an immediate workaround, you can try
using --no-sandbox.

MobileFirst Server not startng untill JVM.options is edited in Windows 8.1

I have faced a problem like Mobilefirst server not starting until i
edit the JVM.options (-DOS.name = Windows 8) in the eclipse.
I need to do the above step manually whenever i create a new workspace
Is there
any other way to completely resolve this problem.
Note : I am using Windows 8.1
Error Log
Listening for transport dt_socket at address: 10777
CWWKE0005E: The runtime environment could not be launched.
CWWKE0018E: An exception occurred while launching the runtime environment: java.lang.IllegalArgumentException: WebSphere-DefaultExtension-windowsnt(unknown)
com.ibm.ws.kernel.boot.LaunchException: Caught unexpected exception java.lang.IllegalArgumentException: WebSphere-DefaultExtension-windowsnt(unknown)
at com.ibm.ws.kernel.boot.internal.KernelBootstrap.rethrowException(KernelBootstrap.java:418)
at com.ibm.ws.kernel.boot.internal.KernelBootstrap.go(KernelBootstrap.java:183)
at com.ibm.ws.kernel.boot.Launcher.createPlatform(Launcher.java:131)
at com.ibm.ws.kernel.boot.Launcher.main(Launcher.java:55)
at com.ibm.ws.kernel.boot.cmdline.EnvCheck.main(EnvCheck.java:52)
Caused by: java.lang.IllegalArgumentException: WebSphere-DefaultExtension-windowsnt(unknown)
at java.util.jar.Attributes$Name.<init>(Unknown Source)
at java.util.jar.Attributes.getValue(Unknown Source)
at com.ibm.ws.kernel.boot.internal.BootstrapManifest.getOSExtensionDefinition(BootstrapManifest.java:157)
at com.ibm.ws.kernel.boot.internal.KernelBootstrap.go(KernelBootstrap.java:123)
... 3 more
Try adding that option to the eclipse.ini file located in your Eclipse installation folder, instead of in the JVM.options of your workspace.

Unable to start development server in debug mode

When I'm starting the MobileFirst Server in debug mode, it fails loading with the following error message:
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
Error occurred during initialization of VM
agent library failed to init: jdwp
How Can I solve this?
The MobileFirst Development Server is by default in debug mode... so when you try to start the server using the "debug mode" icon, it fails in doing so because the debug definition cannot be set twice, which is what the error message says.
To start the server in debug mode, simply start it as you would normally do it, by clicking on the "play" button.
After doing so, you can spot the following line: "Listening for transport dt_socket at address: 10777".
This means the server started in debug mode.

Server Worklight Development Server failed to start

I have install latest version of IBM Worklight on Marketplace of eclipse juno. I have create a new project and then run my project Run As > Run on Worklight Development Server. then i have face an error on the server. Please Help me.
Thanks
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
objc[42627]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
/Users/apple/Downloads/eclipse 2/plugins/com.worklight.studio.plugin_6.2.0.00-20140904-1709/liberty/wlp/bin/server: line 710: 42627 Abort trap: 6 "${JAVA_CMD}" "$#"
Your Log says Address Already in use. Restart your eclipse. Make sure process is killed.
Either your eclipse did not exit gracefully or some other application is using the port.
If some application is using the port go to server view of eclipse, expand "worklight development server" and change port in "server.xml" file. Hope that helps
According to your error message it is clearly saying that address already in use , this means the port number id using java.exe in background process.so this time if you stop server also this will not release.For this please do the following.
1.Download TCPView from http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx for windows.
2.Install TcpView , after that you will find the port number say 10080.Right click on port number and end process.Now Clean the project and run the server.
Hope this helps.