I have an application with the source code as follows, but always get the error:
"error: (SocketException) java.net.SocketException: Connection reset"
Please help me, I have no experience with this problem, Thank you very much.!
PS. I have added this text into my Manifest
SetApplicationAttribute(android:usesCleartextTraffic, "true")
CreateResourceFromFile(Macro, Core.NetworkClearText)
"error: (SocketException) java.net.SocketException: Connection reset"
Please help me, I have no experience with this problem, Thank you very much.!
Test Connect to Ntrip caster Server:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SocketNTA As Socket
Private AStreamNTrip As AsyncStreamsText
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
SocketNTA.Initialize("SocketNTA")
End Sub
Private Sub Button1_Click
Try
If SocketNTA.Connected Then SocketNTA.Close
SocketNTA.Connect("14.238.1.125", 2101, 10000) 'timeout after 10 seconds
Wait For SocketNTA_Connected (Success As Boolean)
Log(Success)
If Success = False Then
Log("Server did not respond.")
Return
End If
Catch
Log(LastException)
End Try
Dim msg As String
msg = "GET / HTTP/1.1" & Chr(10) & Chr(13)
msg = msg & "User-Agent: NTRIP LefebureNTRIPClient/20131124" & Chr(10) & Chr(13)
msg = msg & "Ntrip-Version: Ntrip/2.0" & Chr(10) & Chr(13)
msg = msg & "Accept: */*" & Chr(10) & Chr(13)
msg = msg & "Connection: close" & Chr(10) & Chr(13)
msg = msg & Chr(10) & Chr(13)
If AStreamNTrip.IsInitialized Then AStreamNTrip.Close
AStreamNTrip.Initialize(Me,"AStreamNTRIP", SocketNTA.InputStream, SocketNTA.OutputStream)
AStreamNTrip.Write(msg)
Wait For AStreamNTRIP_NewText(Text As String)
Log(Text)
End Sub
Private Sub AStreamNTRIP_NewText(Text As String)
Log(Text)
End Sub
Private Sub AStreamNTRIP_Terminated
Log("Connection NTRIP terminated")
End Sub
PS. I have added this text into my Manifest
SetApplicationAttribute(android:usesCleartextTraffic, "true")
CreateResourceFromFile(Macro, Core.NetworkClearText)