This post refers to the Android HTTP Server as seen in the following link:
https://www.b4x.com/android/forum/threads/embed-an-http-server-in-your-android-application.25984/
I tried using the http server by sending with POST a name value pair from vb.net (WinForms app) with the following code:
(the sValue variable length is about 3850 characters)
The code in the 'http server' project in B4A is:
When I compile the b4a project in debug mode everything works perfect. When I turn the compile mode in 'Release (obfuscated)' I get the error in the VB.NET app:
"The request was aborted: The request was canceled."
The error seen on the b4a side in logs is :"(NetworkOnMainThreadException) android.os.NetworkOnMainThreadException"
The errors as seen above are exactly what I get and there are not any more info on them in order to guide me search in the internet for a solution.
Any Ideas and suggestions on this?
Thanks
https://www.b4x.com/android/forum/threads/embed-an-http-server-in-your-android-application.25984/
I tried using the http server by sending with POST a name value pair from vb.net (WinForms app) with the following code:
(the sValue variable length is about 3850 characters)
B4X:
If sInfServ = "" Then
sTempInfServ = InputBox("""Device address"" reported by http server:", "Insert IP", "")
sTempInfServ = sTempInfServ.Replace(",", ".")
Else
sTempInfServ = sInfServ
End If
Dim nv As New NameValueCollection
Dim sValue As String = Uri.EscapeDataString(sJson)
nv.Add("json", sValue)
Using webcl As New WebClient
Try
Dim b() As Byte
b = webcl.UploadValues("http://" & sTempInfServ & ":5556/nvget/", nv)
MsgBox(System.Text.Encoding.UTF8.GetString(b))
sInfServ = sTempInfServ
Catch ex As Exception
MsgBox("Internal error: " & ex.Message)
sInfServ = ""
End Try
End Using
The code in the 'http server' project in B4A is:
B4X:
Sub HandleNVGET (Request As ServletRequest, Response As ServletResponse)
Try
Dim sJson As String = DecodePath(Request.GetParameter("json"))
Dim jp As JSONParser
jp.Initialize(sJson)
Dim l As List
l.Initialize
l = jp.NextArray
.
.
.
.
.
Catch
Log(LastException)
Response.SendString("Received the data but an error occured.")
End Try
End Sub
When I compile the b4a project in debug mode everything works perfect. When I turn the compile mode in 'Release (obfuscated)' I get the error in the VB.NET app:
"The request was aborted: The request was canceled."
The error seen on the b4a side in logs is :"(NetworkOnMainThreadException) android.os.NetworkOnMainThreadException"
The errors as seen above are exactly what I get and there are not any more info on them in order to guide me search in the internet for a solution.
Any Ideas and suggestions on this?
Thanks