UnknownHostException on InitializePost2

danvica

Member
Licensed User
Longtime User
I use a service to schedule a call to a PHP script using InitializePost2.

Everything's fine up to several hours running, I cannot be more precise, then it start receiving back a java.net.UnknownHostException error until I restart the emulator (or stop the service on the phone).

Basically the code is:

B4X:
sub SendReq
    
    ...

    req.InitializePost2(adrstr, " ".GetBytes("UTF8"))
    hcPos.Execute(req, 1)

end sub

Sub hcPos_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
   Dim Message As String
   
    Log("Error UPDPOS: " & Reason & ", StatusCode: " & StatusCode)
   
    If Response <> Null Then
        Log(Response.GetString("UTF8"))
        Response.Release
    End If
end sub
      
Sub hcPos_ResponseSuccess (Response As HttpResponse, TaskId As Int)
    Dim res As String
    Dim parser As JSONParser
    Dim MsgList As List
    
    res = Response.GetString("UTF8")

    Log("Response SMSG " & TaskID & " from server: " & res)
   
    parser.Initialize(res)

    MsgList = parser.NextArray

... do something 
        
    response.Release
End Sub

Do i have to free something ?
 

danvica

Member
Licensed User
Longtime User
Well, I don't know. I haven't changed my procedures bacause I went a little more deep into HttpUtils and saw that they too use the same basic functions.

I think I'm not going to solve the problem using them ? Will I ?

Actually on a real phone I found, sometimes, the same problem... but I'm not sure about the cause since I haven't saved any log file. I'll do it and let you know.

Thanks.
 
Upvote 0
Top