Android Question NTRIP Mount Points

Terradrones

Active Member
Licensed User
Hi All

I need help again please. I want to access the Service Provider (www.trignet.co.za) that has GPS Base Stations all over South Africa that transmits GPS corrections. I have registered with Trignet and have a Username and Password. I also know the IP address and Port number of Trignet.

I am trying to access the mountpoints with the following code:

B4X:
Sub FindMountPoints
    Dim su As StringUtils
    Dim HttpClient As HttpJob
    HttpClient.Initialize("NTRIP", Me)
    
    ' Set the NTRIP caster URL and credentials
    Dim IPAddress As String = CGlobals.DF(64)
    Dim Port As String = CGlobals.DF(65)
    Dim NTRIP_URL As String = "http://" & IPAddress & ":" & Port '& "/caster"
    Dim Username As String = CGlobals.DF(66)
    Dim Password As String = CGlobals.DF(67)
    
    ProgressDialogShow2("Searching Mount Points...", True)
    
    Dim AuthString As String = Username & ":" & Password
    Dim AuthHeader As String = "Basic " & su.EncodeBase64(AuthString.GetBytes("UTF8"))
    HttpClient.Download(NTRIP_URL)
    
    ' Set headers before sending the request
    HttpClient.GetRequest.SetHeader("Authorization", AuthHeader)
    HttpClient.GetRequest.SetHeader("User-Agent", "Ceaser")
    HttpClient.GetRequest.SetHeader("Accept", "*/*")
    HttpClient.GetRequest.SetHeader("Connection", "close")
    
    ' Send the request
'    HttpClient.Download(NTRIP_URL)
End Sub

Sub JobDone (Job As HttpJob)
    If Job.Success Then
        CmbMountPoints.cmbBox.Clear
        Dim response As String = Job.GetString
'        Log("NTRIP Response: " & response)
        
        ' Process the NTRIP data here to extract mount points
        Dim MountPoints As List
        MountPoints.Initialize
        Dim Lines() As String = Regex.Split(CRLF, response)
        For Each Line As String In Lines
            Log(Line)
            If Line.StartsWith("STR") Then
                CmbMountPoints.cmbBox.Add(Line)
'                Log(Line)
                MountPoints.Add(Line)
            End If
        Next
        Log("Available Mount Points: " & MountPoints)
    Else
        Log("Job failed: " & Job.ErrorMessage)
        Log("HTTP Status Code: " & Job.Response.StatusCode) ' Log the status code for more details
'        Log("Full Response: " & Job.GetString) ' Log the full response to understand why it fails
        MsgboxAsync("Mount Points Are Not Available" & CRLF & "The Server Might Be Down", "No Mount Points")
    End If
    Job.Release
    ProgressDialogHide
End Sub

It is giving me the following error:

ResponseError. Reason: java.net.ProtocolException: Unexpected status line: SOURCETABLE 200 OK, Response:
Job failed: java.net.ProtocolException: Unexpected status line: SOURCETABLE 200 OK
HTTP Status Code: -1

What does "sourcetable 200 ok" mean?
 

Terradrones

Active Member
Licensed User
With the following code, if I leave out the "Port", I get all the data that is shown on the Website as the response.

B4X:
Sub FindMountPoints
    Dim su As StringUtils
    Dim HttpClient As HttpJob
    HttpClient.Initialize("NTRIP", Me)
    
    ' Set the NTRIP caster URL and credentials
    Dim IPAddress As String = CGlobals.DF(64)
    Dim Port As String = CGlobals.DF(65)
    Dim NTRIP_URL As String = "http://" & IPAddress '& ":" & Port '& "/caster"
    Dim Username As String = CGlobals.DF(66)
    Dim Password As String = CGlobals.DF(67)
    
    ProgressDialogShow2("Searching Mount Points...", True)
    
    Dim AuthString As String = Username & ":" & Password
    Dim AuthHeader As String = "Basic " & su.EncodeBase64(AuthString.GetBytes("UTF8"))
    HttpClient.Download(NTRIP_URL)
    
    ' Set headers before sending the request
    HttpClient.GetRequest.SetHeader("Authorization", AuthHeader)
    HttpClient.GetRequest.SetHeader("User-Agent", "Ceaser")
    HttpClient.GetRequest.SetHeader("Accept", "*/*")
    HttpClient.GetRequest.SetHeader("Connection", "close")
    
    ' Send the request
'    HttpClient.Download(NTRIP_URL)
End Sub

Sub JobDone (Job As HttpJob)
    CmbMountPoints.cmbBox.Clear
    If Job.Success Then
        Dim response As String = Job.GetString
        '        Log("NTRIP Response: " & response)
        
        ' Process the NTRIP data here to extract mount points
        Dim MountPoints As List
        MountPoints.Initialize
        Dim Lines() As String = Regex.Split(CRLF, response)
        For Each Line As String In Lines
            Log(Line)
            If Line.StartsWith("STR") Then
                CmbMountPoints.cmbBox.Add(Line)
                '                Log(Line)
                MountPoints.Add(Line)
            End If
        Next
        Log("Available Mount Points: " & MountPoints)
    Else
        Log("Job failed: " & Job.ErrorMessage)
        Log("HTTP Status Code: " & Job.Response.StatusCode) ' Log the status code for more details
        Log(Job.Response.ErrorResponse)
        '        Log("Full Response: " & Job.GetString) ' Log the full response to understand why it fails
'        MsgboxAsync("Mount Points Are Not Available" & CRLF & "The Server Might Be Down", "No Mount Points")
    End If
    Job.Release
    ProgressDialogHide
End Sub
 
Upvote 0

Terradrones

Active Member
Licensed User
Hi DonManfred, I think you misunderstood me. Using the coding above I get the data on Trignet's website....that what you see when you onto their website. I cannot access the mountpoints.

Somebody gave me a link to code that is in VB.net. I am busy translating it to B4A.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
My answer was an answer to #20 from @drgottjr
He got rhe SOURCETABLE 200 OK already. Would be interesting if the content of this call IS the mointpoint-list. This is what i would expect.

I can not give out my code for an NTRip-Client as it was a exclusive work for a customer.

I just want to try to - maybe - give any hint of what is missing or needs to be done.
 
Upvote 0

Terradrones

Active Member
Licensed User
The following code is very similar to the one of the VB.net example. I used "Ctwn-SB" which is the mountpoint at Cape Town.

Still no response.

B4X:
Sub FindMountPoints
    Dim su As StringUtils

    'Set the NTRIP caster URL and credentials
    If AStream.IsInitialized Then AStream.Close
    IPAddress = CGlobals.DF(64)
    Port = CGlobals.DF(65)
    Username = CGlobals.DF(66)
    Password = CGlobals.DF(67)
    MountPoint = "Ctwn-SB"    'CGlobals.DF(71)
    Socket.Initialize("Socket")
    Socket.Connect(IPAddress, Port, 10000)
End Sub

Sub Socket_Connected (Successful As Boolean)
    If Successful Then
        Log("Connected successfully.")
        ' Proceed with data exchange
        Dim msg As String
        msg = "GET /" & MountPoint & " HTTP/1.0" & CRLF
        msg = msg & "User-Agent: NTRIP Ceaser" & CRLF
        msg = msg &  "Accept: */*" & CRLF
'        msg = msg &  "Connection: close" & CRLF
        If Username.Length > 0 Then
            Dim auth As String = su.EncodeBase64((Username & ":" & Password).GetBytes("UTF8"))
            msg = msg & "Authorization: Basic " & auth & CRLF
        End If
        
        AStream.Initialize(Socket.InputStream, Socket.OutputStream, "AStream")
        Log("Request sent: " & msg)
        
        AStream.Write(msg.GetBytes("UTF8"))
        Sleep(200)
    Else
        Log("Connection failed.")
    End If
End Sub

Sub AStream_NewData (Buffer() As Byte)
    Dim Response As String = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
    Log("Response: " & Response)
    
    ' Parse the response manually to extract mount points
    Dim Lines() As String = Regex.Split(CRLF, Response)
    For Each Line As String In Lines
        If Line.StartsWith("STR") Then
            Log("Mount Point: " & Line)
            CmbMountPoints.cmbBox.Add(Line)
        End If
    Next
End Sub

Any suggestions please?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
and in the content you have got a list of endpoints? Must be in this 111934 bytes...
correct. but it's a complete "file". that means the server is using http. an ntrip client is something different. the server i found accepts http or ntrip. i tried http and got a big file. that's why i'm suggesting op's server might handle both protocols...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
an ntrip client is something different
Yes, but you can do all of them using okhttputils and AsyncStreams.

After the SOURCETABLE 200 OK (which holds the mointpointlist) you have to Authenticate with the Caster using an Base64 Encrypted usernameassword Pair and using special headers defining which mointpoint you want access over the already connected AStream

You have to send a special code after authenticated. Don´t remember which one exactly.

You send a command then and get the answer to this command in the AStream. You´ll have to parse the result by yourself afterwards. That´s part of the NTRip-Protocol.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
@DonManfred - atttached is what i got (via http) from the particular server i found (http://rtk2go.com:2101/). i have no idea what it all means. without a login and password, it was impossible to do any testing for op. i found a server that didn't require them, and it gave me the attached.
 

Attachments

  • ntrip.txt
    109.7 KB · Views: 28
Upvote 0

Terradrones

Active Member
Licensed User
Hi Drgottjr, those are Mountpoints. The "STR" indicates that it is a Mountpoint and the second name after the ";" is the name of the Mountpoint. In the string is also what type of correction it transmits (RTCM 3.3, RTCM 3.2, etc.) and the satellites it uses.

How did you do it please?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
Upvote 0

Terradrones

Active Member
Licensed User
I used your address in my program and I get all the mountpoints from that site. This means our system is not working. This makes me upset as I have been trying more than a week now. Thought that I was getting stupid due to old age
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
When I send "http://trignet.co.za:2101" it tells me that Trignet sent me an invalid response. Maybe our system is down again.
okhttp uses a web client which expects http protocol. your server is up, it's answering, but okhttputils does not know what to do with SOURCETABLE 200 OK because it isn't http protocol. either you find out how to get an ntrip client or you write a simple socket routine. our async sockets might work; you just have to piece things together
as they come in until nothing else comes in. you were trying to do the piecing together as part of the astream_newdata method. just take what comes in and add it to
a global stringbuilder, eg. when data stop coming, you deal with the stringbuilder.

i think the fact that the server answers with "sourcetable 200 ok" means that you either write your own socket routine or keep fiddling with async sockets. the server wants to tell you.

look, i'm only interested in solving a problem. pm me your login and password so i can work on it. otherwise i'm just guessing.
 

Attachments

  • log.png
    91.6 KB · Views: 33
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
I used your address in my program and I get all the mountpoints from that site. This means our system is not working. This makes me upset as I have been trying more than a week now. Thought that I was getting stupid due to old age
As drgottjr said, "your server is up." you can get the reply from the server.
Ref to the example Erel provided post #2 and drgottjr said at post #36.

 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
atttached is what i got (via http) from the particular server i found
It is what i expected. A List of Mountpoints the Server provides.
After you get this you have to choose one of these Mountpoints and use a Socket and Asyncstreams to communicate with the Caster.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
here's what i get from "your" server using a plain (non-http) socket. is this the data you are expecting? it's the same kind of data i got with a browser and that @teddybear got with curl. it doesn't seem to work with okhttputils because of the http version the server wants. both ok's http client (used by okhttputils) and java's own httpclient don't accept http 1.0 or 0.9. with a regular socket, you can put whatever version you want. the only issue with using a plain socket is you have to pretend you're an http client.
 

Attachments

  • ntrip.txt
    10 KB · Views: 22
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…