Android Question ResponseError. Reason: java.net.SocketTimeoutException: timeout

carlos7000

Well-Known Member
Licensed User
Longtime User
I am developing an application that makes about 215 requests to Bittrex through its api.

After a while the application crashes and this message appears:

B4X:
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
java.lang.RuntimeException: java.io.FileNotFoundException: /data/data/com.BittrexHelper.PensamientoProfundo/cache/5091: open failed: EMFILE (Too many open files)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:223)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:615)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4895)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.io.FileNotFoundException: /data/data/com.BittrexHelper.PensamientoProfundo/cache/5091: open failed: EMFILE (Too many open files)
    at libcore.io.IoBridge.open(IoBridge.java:416)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:370)
    at anywheresoftware.b4a.samples.httputils2.httputils2service._hc_responsesuccess(httputils2service.java:168)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    ... 10 more
Caused by: libcore.io.ErrnoException: open failed: EMFILE (Too many open files)
    at libcore.io.Posix.open(Native Method)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
    at libcore.io.IoBridge.open(IoBridge.java:400)
    ... 16 more

I guess the message ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response: Indicates that some responses to requests for data did not arrive or arrived late, so the timeout is exceeded.

Although it reduced the number of requests, sometimes some request that does not get a response.

As some messages arrive late or never arrive, ¿how do I capture the problem and act according to the type of problem, without the application breaking down?
 

DonManfred

Expert
Licensed User
Longtime User
(Too many open files
This is the problem.
Are you calling 215 request paralel?
Did you not close the files used/copied?

HARD to help without seeing what you have done and how.
 
Upvote 0
Top