Hi, All
I'm going on development of RTSP-grabber using simple HTML-form.
When the IP-camera is working stable - all in my server web-app is controlled OK via browser web-page.
But i add checking the camera: ping inside the timer (timer in the Main module) before trying to grab the frame.
Web-page from jServer v.4.01 is with refreshing each 10 seconds to update the system state
And the server hangs after each event: if the camera is switched off or switched on: browser at refreshing moment does not stop loading web-page. No any error log messages, just all is hanging (until server restart).
How to understand it and debug ?
Also i remember that i saw such server hanging if to use Sleep(x)...
I'm going on development of RTSP-grabber using simple HTML-form.
When the IP-camera is working stable - all in my server web-app is controlled OK via browser web-page.
But i add checking the camera: ping inside the timer (timer in the Main module) before trying to grab the frame.
B4X:
Sub PingCamera (host As String, timeoutMs As Int) As Boolean
Private inetaddress As JavaObject
inetaddress.InitializeStatic("java.net.InetAddress")
Dim b As Boolean = inetaddress.RunMethodJO("getByName",Array As String(host)).RunMethod("isReachable",Array As Object(timeoutMs))
Return b
End Sub
Sub tim_tick
If Grabbing = False Then
Return
End If
Dim H As String = Get_Host(RTSP_URL)
If PingCamera(h, 500) = False Then
LastGrabbingError = H & " is not reachable"
Log(LastGrabbingError)
Return
Else
Log("!")
Get_Frame
End If
End Sub
'parse the host to use for Ping
Sub Get_Host(u As String) As String
Dim m As Matcher = Regex.Matcher("(.*:)//([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)", u)
Do While m.Find
For g = 1 To m.GroupCount
If g = 2 Then 'host name
Return m.Group(g)
End If
Next
Loop
Return ""
End Sub
Web-page from jServer v.4.01 is with refreshing each 10 seconds to update the system state
And the server hangs after each event: if the camera is switched off or switched on: browser at refreshing moment does not stop loading web-page. No any error log messages, just all is hanging (until server restart).
How to understand it and debug ?
Also i remember that i saw such server hanging if to use Sleep(x)...
Last edited: