ReactNative app crashes FATAL EXCEPTION: OkHttp Dispatcher - crash

I am making a request to the api with axios and after getting the results, the app crashes. I mention that the request returns only json text.
The request finishes successfully, promise returns success, only thing is that the app crashes without debug logs, only the provided logcat log.
Process: host.exp.exponent, PID: 23720
java.lang.OutOfMemoryError: Failed to allocate a 25090000 byte allocation with 6291456 free bytes and 18MB until OOM, max allowed footprint 390069440, growth limit 402653184
at java.lang.StringBuilder.toString(StringBuilder.java:410)
at android.util.JsonReader.nextString(JsonReader.java:894)
at android.util.JsonReader.nextValue(JsonReader.java:708)
at android.util.JsonReader.objectValue(JsonReader.java:691)
at android.util.JsonReader.peek(JsonReader.java:347)
at abi31_0_0.com.facebook.react.devsupport.JSDebuggerWebSocketClient.onMessage(JSDebuggerWebSocketClient.java:187)
at expolib_v1.a.a.i.a.b(RealWebSocket.java:307)
at expolib_v1.a.a.i.c.e(WebSocketReader.java:222)
at expolib_v1.a.a.i.c.a(WebSocketReader.java:101)
at expolib_v1.a.a.i.a.b(RealWebSocket.java:262)
at expolib_v1.a.a.i.a$2.onResponse(RealWebSocket.java:201)
at expolib_v1.a.y$a.c(RealCall.java:135)
at expolib_v1.a.a.b.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
I expected it to work... instead, I get this error message.

Related

Mule 3.9 logs HTTP response sending task failed with error: Locally closed

I use ApiKit to receive queries. Occasionally I get the following line in a log file:
WARN org.mule.module.http.internal.listener.grizzly.ResponseCompletionHandler - HTTP response sending task failed with error: Locally closed
It seems that in this case the integration has not sent a response to the party that called the integration. I thought that there might be a sort of timeout before ApiKit closes the connection to caller but based on timestamps that might not be the case as everything happens within a second.
In this case the payload is sent to Artemis queue before this warning and despite the warning the message is read from Artemis normally and the whole flow works otherwise just fine besides this warning and not sending the response.
So, am I correct when I think that this warning is an indication why the response is not sent? In addition to that what can be done to prevent this situation?

Okhttp error during React Navtive GET request

Receiving this error during an otherwise valid GET request in a react-native project.
2020-08-11 12:12:54.163 7301-7498/com.cigna.mobile.mycigna.debug E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.cigna.mobile.mycigna.debug, PID: 7301
java.lang.NoSuchMethodError: No static method delimiterOffset(Ljava/lang/String;IILjava/lang/String;)I in class Lokhttp3/internal/Util; or its super classes (declaration of 'okhttp3.internal.Util' appears in /data/app/~~-wSG5UWGWR49_zqj0uGdfw==/com.cigna.mobile.mycigna.debug-O6Kl4LYWC-jBUFRzAxGZug==/base.apk!classes6.dex)
at okhttp3.JavaNetCookieJar.decodeHeaderAsJavaNetCookies(JavaNetCookieJar.java:91)
at okhttp3.JavaNetCookieJar.loadForRequest(JavaNetCookieJar.java:74)
at com.facebook.react.modules.network.ReactCookieJarContainer.loadForRequest(ReactCookieJarContainer.java:44)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:75)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
at okhttp3.RealCall$AsyncCall.run(RealCall.kt:136)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2020-08-11 12:12:54.552 631-716/system_process E/InputDispatcher: channel '94b38db com.cigna.mobile.mycigna.debug/com.cigna.mycigna.ui.dashboard.HomeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
All other api requests on my application work without problem. As well, the request mentioned works seemlessly on iOS.
You've got two libraries: okhttp and okhttp-urlconnection. They must be on the same exact version or you may receive this error.

JVM Appears to be hung with Outofheapspace error while having response payload size more than 3 mb in Mule 4

I am using mule 4 to retrieve records from database and show it in the response . Somehow I see all the components are getting passed successfully but while streaming the response its failing . I am trying to call from postman and I see error:
<h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
In the studio , I get logs like :
Pinging the JVM took 9 seconds to respond.
JVM appears hung: Timed out waiting for signal from JVM. Requesting thread dump.
Dumping JVM state.
JVM appears hung: Timed out waiting for signal from JVM. Restarting JVM.
JVM exited after being requested to terminate.
JVM Restarts disabled. Shutting down.
<-- Wrapper Stopped
Could anyone help me on this .
Thanks
Sanjukta
Some information is not being streamed. You didn't provide any details of the implementation but clearly something is consuming a lot of heap memory. It may not be the database, but some other component. Check the streaming configuration for your components.
To identify the cause locally you can capture a heap dump and analyze it while the runtime in studio is timing out for the ping before it crashes. That is probably because of high garbage collection activity.
This is a symptom that your JVM heap memory is full, check your settings in Anypoint Studio and see how much is allocated
Check this article
https://help.mulesoft.com/s/article/Out-Of-Memory-in-Studio-Application-How-to-increase-the-maximum-heap-size?r=6&ui-force-components-controllers-recordGlobalValueProvider.RecordGvp.getRecord=1

Is it possible to upload large files to Ktor & Netty server?

I was making a simple file upload&download service and found out that, as far as I understand, Netty doesn't release direct buffers until request processing is over. As a result, I can't upload bigger files.
I was trying to make sure that the problem is not inside my code, so I created the most simple tiny Ktor application:
routing {
post("upload") {
call.receiveMultipart().forEachPart {}
call.respond(HttpStatusCode.OK)
}
}
The default direct memory size is about 3Gb, to make test simpler I limit it with:
System.setProperty("io.netty.maxDirectMemory", (10 * 1024 * 1024).toString())
before starting the NettyApplicationEngine.
Now if I upload a large file, for example with httpie, I got "Connection reset":
http -v --form POST http://localhost:42195/upload file#/tmp/FileStorageLoadTest-test-data1.tmp
http: error: ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) while doing POST request to URL: http://localhost:42195/upload
On the server side there is no information about the problem except for the "java.io.IOException: Broken delimiter occurred" exception. But if I put the breakpoint in NettyResponsePipeline#processCallFailed, the real exception is:
io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 65536 byte(s) of direct memory (used: 10420231, max: 10485760)
It is a pity that this exception is not logged.
Also, I found out that the same code works without problems if I use Jetty engine instead.
Environment:
Ubuntu Linux
Java 8
Ktor=1.2.5
netty-transport-native-epoll=4.1.43.Final
(but if Netty started without native-epoll support, the problem is the same)

okhttp 3.7.0 SSL Shutdown failed threw UnknownHostException and not SSLException

While making a network request with low connectivity very rarely I see that I get
<-- HTTP FAILED: java.net.UnknownHostException: Unable to resolve host ....
while my server seems to have got the request correctly. I found 1 instance of it with device logs which shows actually an SSLException happened
D/NativeCrypto: jniThrowException: javax/net/ssl/SSLException: Read error: ssl=0x7dc365f080: I/O error during system call, Software caused connection abort
D/NativeCrypto: jniThrowException: javax/net/ssl/SSLException: SSL shutdown failed: ssl=0x7dc365f080: I/O error during system call, Broken pipe
My question is why does okhttp and retrofit throw UnknownHostException and not SSLException, and is there a way to actually get the SSLException as currently my app thinks the request did not go while server processes that request.
I am using
okhttp:3.10.0
retrofit:2.2.0
adapter-rxjava2:2.2.0