HTTP-Lib : ResponseCode -1 after 2 success

matahari

Member
Licensed User
Longtime User
Hy,

after the first difficulties basic4pcc does what I want :) Fantastic simple!
But something in my testapp makes me crazy.
I want to display a Text-String from a webpage every 5 seconds (async). So i have a timer (hc) that fires every 5 seconds.

B4X:
Sub hc_tick
If menu5.Checked=True Then         'Load-from-web Checkbox
   holdconnection                  'Catch data
   hc.Enabled = False               'Disable timer
End If 
End Sub

Sub holdconnection()
getIP_request.New1("http://www.start.sl/connect")      'Init Request
   getIP_request.TimeOut  = 10000                   'Timout after 10s
   getIP_response.New1                           'Init Response
   getIP_request.GetAsyncResponse                   'Handle Request async
End Sub

Sub getIP_request_response
If getIP_request.ResponseCode = 200 Then            'HTTP200=OK
   getIP_response.Value = getIP_request.AsyncResponse  'Set Response-value
      ipaddr.Text=getIP_response.GetString            'Write response to form 
Else                                       'HTTP<>200!=OK
   ipaddr.Text="ERR " & getIP_request.ResponseCode      'Display ResponseCode
End If
   hc.Enabled = True                           'Enable timer
End Sub

This will work exactly 2 times. After the 2nd time the ResponseCode is -1 (forever). When i close the app and restart it again - 2 times good, than -1

What´s wrong with my code?

Regards
Matze

PS.: the timeout is not relevant
 
Top