Network login

pa0zhb

New Member
Licensed User
Longtime User
Hi all, i am busy with the socket example:sign0085:
I need to log-in at my server with a username and password.
when i look at the data what enters the server, no username or password is given, in fact i see nothing at all.
the socket is connected because i have no Message

What do i wrong?

If Successful = False Then
Msgbox(LastException.Message, "Error connecting")
Return
End If

Dim tw As TextWriter

tw.Initialize(Socket1.OutputStream)

tw.WriteLine("GET /?status")
tw.WriteLine("Authorization: Basic axxxxxxxxxxx")
tw.WriteLine("Host: www.xxxxxx.nl")


greetings and tnx in advance, Henk
 

pa0zhb

New Member
Licensed User
Longtime User
Hi Erel, i have done that but here the same problem.:BangHead:

'Activity module
Sub Globals
Dim b4a As String
b4a = "http://xx.xx.x.108:4000"
End Sub

Sub Activity_Create (FirstTime As Boolean)
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.PostString("Job1", b4a, "req=status")
End Sub

Sub JobDone (Job As String)
Dim s As String
If HttpUtils.IsSuccess(b4a) Then
Log(HttpUtils.GetString(b4a))
' s = HttpUtils.GetString(b4a)
' Msgbox("received: " & s, "")
' Else
' Msgbox("no connection " , "")
End If
End Sub


the point is: if i monitor the data arrive at the server, i miss the "req=status" part.
i see: POST /HTTP/1.1
Content-type: application/x-www-form-urlencoded
content-Length: 12
Connection: Close

about your HttpUtilsExample: it's static, only a picture at the screen, nothing more.

greetings, henk
 
Upvote 0

pa0zhb

New Member
Licensed User
Longtime User
I tried this and this is the result in log:

(start log unfiltered)
>>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
CheckJNI is ON
--- registering native functions ---
Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=anywheresoftware.b4a.samples.httputils/.main }
Shutting down VM
adbd disconnected
NOTE: attach of thread 'Binder Thread #3' failed
Start proc anywheresoftware.b4a.samples.httputils for activity anywheresoftware.b4a.samples.httputils/.main: pid=562 uid=10038 gids={3003}
GC_EXPLICIT freed 149 objects / 11488 bytes in 2732ms


** Activity (main) Create, isFirst = true **
Starting Job: Job1
** Activity (main) Resume **
Displayed activity anywheresoftware.b4a.samples.httputils/.main: 3535 ms (total 3535 ms)
** Service (httputilsservice) Create **
** Service (httputilsservice) Start **
GC_FOR_MALLOC freed 3579 objects / 215200 bytes in 146ms

Default buffer size used in BufferedOutputStream constructor. It would be better to be explicit if an 8k buffer is required.

?POST variables:
array(1) {
["/req"]=>
string(6) "status"
}

GET variables:
array(0) {
}
** Service (httputilsservice) Destroy **
GC_EXPLICIT freed 694 objects / 40144 bytes in 246ms
GC_EXPLICIT freed 6 objects / 176 bytes in 430ms

(end log)

Erel, all i need is to login at the server with /req=status.
then the server answers with xml with data from sensors.

i switch of for the moment the username and password stuff so the server always respond when received /req=status command.

this is working for more then 2 years now and we now want to make a app so that members of our club can check the data mobile.

i hope you find something in the log

thank you for your patients, henk
 
Upvote 0
Top