Android Question HttpJob error using OkHttpUtils2

jeronimovilar

Active Member
Licensed User
Longtime User
I´m tryng a request in my intranet by local ip. But NOT working
The log: "Errojava.net.SocketTimeoutException: timeout - anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpResponse@bd66fa9"

B4X:
    mIP = "192.168.1.145"
    Dim ServerUrl As String = "http://" & mIP & "/Campeonato/TempoTimer.asp?T=00:" & XXX
    Dim j As HttpJob
    j.Initialize("",Me)
    j.GetRequest.Timeout = 1000
    j.Download(ServerUrl) '    j.Download("http://" & IP)
    Wait For (j) JobDone(j As HttpJob)
    ProgressDialogHide
    If j.Success Then
        xOkPing = xOkPing + 1
        Log("OK " & XXX)
    Else ' FireWall bloqueando
        xErrPing = xErrPing + 1
        ToastMessageShow("Erro na Rede para RESETAR tempo" & j.Response, True)
        Log("Erro" & j.ErrorMessage & " - " & j.Response)
    End If
    j.Release

Why?
 

teddybear

Well-Known Member
Licensed User
Try to comment the j.GetRequest.Timeout = 1000
B4X:
'j.GetRequest.Timeout = 1000
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
?
B4X:
''    Test 1
'    Dim sLink As String = "https://l192.168.1.145/Campeonato/TempoTimer.asp"
'    Dim sTime As String = "00:20"
'    Dim Parameters() As String = Array As String ("T", sTime)

'    Wait For (GetURL(sLink, Parameters)) Complete (DataResult As String)
'    Log(DataResult)

'    Test 2 no parameters
    Dim sLink As String = "https://www.google.com"
    Dim Parameters() As String

    Wait For (GetURL(sLink, Parameters)) Complete (DataResult As String)
    Log(DataResult)

B4X:
Public Sub GetURL(URL As String, Parameters() As String) As ResumableSub
    Dim mResult As Map
    Dim j As HttpJob
    Try
        j.Initialize("", Me)
        j.Download2(URL, Parameters)
        j.GetRequest.Timeout = 60 * DateTime.TicksPerSecond 'time 60 second
        Wait For (j) JobDone(j As HttpJob)
        If j.Success Then
            mResult = CreateMap("Status" : j.Response.StatusCode, "Message" : "Ok" )
        Else
            mResult = CreateMap("Status" : j.Response.StatusCode, "Message" : "Error " & j.Response.ErrorResponse )
        End If
    Catch
        Log(LastException)
    End Try
    j.Release
    Return mResult.As(JSON).ToString
End Sub
Result (JSON)
1687834662821.png
 
Last edited:
Upvote 0

jeronimovilar

Active Member
Licensed User
Longtime User
The problem is my server/computer :(
Installed and tested in another computer (different IP) and works fine.
Thanks and sorry
 
Upvote 0

jeronimovilar

Active Member
Licensed User
Longtime User
The message erro is j.Response.StatusCode: -1 using my IP and file
Whe i delete the file on my server the erro is j.Response.StatusCode: 500
What is the j.Response.StatusCode: -1??
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
The problem is my server/computer :(
Installed and tested in another computer (different IP) and works fine.
Thanks and sorry
?????

j.GetRequest.Timeout = 1000
j.Download(ServerUrl) ' j.Download("http://" & IP)

Wait For (j) JobDone(j As HttpJob)

Yuor post
B4X:
    mIP = "192.168.1.145"
    Dim ServerUrl As String = "http://" & mIP & "/Campeonato/TempoTimer.asp?T=00:" & XXX
    Dim j As HttpJob
    j.Initialize("",Me)
    j.GetRequest.Timeout = 1000
    j.Download(ServerUrl) '    j.Download("http://" & IP)
    Wait For (j) JobDone(j As HttpJob)
    ProgressDialogHide
    If j.Success Then
        xOkPing = xOkPing + 1
        Log("OK " & XXX)
    Else ' FireWall bloqueando
        xErrPing = xErrPing + 1
        ToastMessageShow("Erro na Rede para RESETAR tempo" & j.Response, True)
        Log("Erro" & j.ErrorMessage & " - " & j.Response)
    End If
    j.Release
 
Upvote 0
Top