Hi,
I'm really struggling with trying to get this to work. No matter what I try I get errors and fail. I'm wondering if i can get an assist. I have read and tried httputils2 but the connection fails or errors. firewall is down and it works successfully with my vb.net code, so i know it's my approach.
What am i missing? Not SSL btw.
Working VB.net code:
This is just one of my attempts and the error (Error: org.apache.http.client.ClientProtocolException)
I am not sure if I am just approaching this completely wrong.
At this point I've been trying for a few days and I got nowhere.
Any help or code hints would be greatly appreciated.
Thanks
I'm really struggling with trying to get this to work. No matter what I try I get errors and fail. I'm wondering if i can get an assist. I have read and tried httputils2 but the connection fails or errors. firewall is down and it works successfully with my vb.net code, so i know it's my approach.
What am i missing? Not SSL btw.
Working VB.net code:
B4X:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
' Dim data1 = Encoding.UTF8.GetBytes("{'command': 'summary'}")
sendCommand("summary")
End Sub
Private Sub sendCommand(ByVal command As String)
Try
Dim clientSocket As New System.Net.Sockets.TcpClient()
clientSocket.Connect("192.168.1.72", 4028)
Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes(command)
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Dim inStream As Byte() = New Byte(65536) {}
serverStream.Read(inStream, 0, CInt(clientSocket.ReceiveBufferSize))
Dim returnData As String = System.Text.Encoding.ASCII.GetString(inStream)
' MsgBox(returnData)
TextBox1.Text = (returnData)
' Debug.Print(returnData)
clientSocket.Close()
Catch exc As Exception
End Try
End Sub
This is just one of my attempts and the error (Error: org.apache.http.client.ClientProtocolException)
I am not sure if I am just approaching this completely wrong.
B4X:
Sub Senddata
Dim job2 As HttpJob
Dim objMap As Map: objMap.Initialize
'Send a POST request
job2.Initialize("Job2", Me)
objMap.Put("command","summary")
Dim objJSon As JSONGenerator: objJSon.Initialize(objMap)
job2.PostString("HTTP://192.168.1.70:4028", objJSon.ToPrettyString(2))
job2.GetRequest.SetContentType("application/json")
End Sub
At this point I've been trying for a few days and I got nowhere.
Any help or code hints would be greatly appreciated.
Thanks