Bug? [RESOLVED] hc.ExecuteCredentials raises java.net.ConnectException

b4auser1

Well-Known Member
Licensed User
Longtime User
B4X:
            ' java.net.ConnectException: Failed to connect to /192.168.0.10:8000
            '     at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.executeWithTimeout(OkHttpClientWrapper.java:156)
            hc.ExecuteCredentials(job.GetRequest, taskCounter, job.Username, job.Password)
When there is no network connection or there is a problem with network connection, OKHttpClient hc.ExecuteCredentials doesn't genertate event hc_ResponseError, but raises exception instead. Try catch construction doesn't intercept the exception.
 

b4auser1

Well-Known Member
Licensed User
Longtime User
1. Can you post the full error message from the logs?
I tried to reproduce error conditions, but failed.
There is now exception in log "java.net.UnknownHostException: ...", and fortunately hc_ResponseError is raised with Reason = java.net.UnknownHostException.
2. Why aren't you using OkHttpUtils2?
I took sources of OkHttpUtils2 and expanded them to save additionally f.e. Reason in HttpJob field. I have kept control flow.
 

b4auser1

Well-Known Member
Licensed User
Longtime User
Finally, I managed to reproduce error conditions (Network presensts, host is down) and got exception "java.net.ConnectException: Failed to connect to ...".
And again, hc_ResponseError is raised with Reason = java.net.ConnectException: Failed to connect to.
So there is no problem in library. It seems that I did something wrong in my code.
 
Top