Android Question HttpJob error

Sofiya

Member
Licensed User
Sub Button1_Click
Dim strUsername As String = EditText1.Text.Trim
If strUsername = "" Then
Msgbox ("Please enter User ID", "Error")
Return
End If
Dim strPassword As String = EditText2.Text.Trim
If strPassword = "" Then
Msgbox ("Please enter Password", "Error")
Return
End If

Dim job1 As HttpJob
job1.Initialize ("Login", Me)
job1.Download2 ("http://192.168.1.4/desktop/login.php", _
Array As String ("UserName", strUsername, "Password", strPassword))
ProgressDialogShow ("Connecting to Server ...")
End Sub

Sub JobDone (Job As HttpJob)
ProgressDialogHide
Log ("JobName =" & Job.JobName & ", Success =" & Job.Success)
If Job.Success = True Then
Dim strReturn As String
Log (Job.GetString)
strReturn = Job.GetString
Label3.Text = strReturn
Else
Log ("Error:" & Job.ErrorMessage)
ToastMessageShow ("Error:" & Job.ErrorMessage, True)
End If
Job.Release
End Sub

i facing the error in the above coding and the error follow

JobName =Login, Success =false
Error:eek:rg.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.4:80 timed out


i can't able to find the exact problem in my coding, pls help me to solve the error, thanks in advance.
 

DonManfred

Expert
Licensed User
Longtime User
Error:eek:rg.apache.http.conn.ConnectTimeoutException
Remove http, httputils2 from your project.
Add okhttp and okhttputils to your project.

Additionally you should USE CODE TAG when posting code.
 
Last edited:
Upvote 0

Sofiya

Member
Licensed User
Remove http, httputils2 from your project.
Add okhttp and okhttputils to your project.

Additionally you should USE CODE TAG when posting code.

i try this suggestion but again i facing a different error and the error follow

java.lang.NoClassDefFoundError: java.net.IDN
at okhttp3.internal.Util.domainToAscii(Util.java:353)
at okhttp3.HttpUrl$Builder.canonicalizeHost(HttpUrl.java:1571)
at okhttp3.HttpUrl$Builder.parse(HttpUrl.java:1365)
at okhttp3.HttpUrl.parse(HttpUrl.java:897)
at okhttp3.Request$Builder.url(Request.java:141)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest.InitializeGet(OkHttpClientWrapper.java:392)
at anywheresoftware.b4a.samples.httputils2.httpjob._download2(httpjob.java:117)
at b4a.example.main._button1_click(main.java:448)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

rscheel

Well-Known Member
Licensed User
Longtime User
i try this suggestion but again i facing a different error and the error follow

java.lang.NoClassDefFoundError: java.net.IDN
at okhttp3.internal.Util.domainToAscii(Util.java:353)
at okhttp3.HttpUrl$Builder.canonicalizeHost(HttpUrl.java:1571)
at okhttp3.HttpUrl$Builder.parse(HttpUrl.java:1365)
at okhttp3.HttpUrl.parse(HttpUrl.java:897)
at okhttp3.Request$Builder.url(Request.java:141)
at anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest.InitializeGet(OkHttpClientWrapper.java:392)
at anywheresoftware.b4a.samples.httputils2.httpjob._download2(httpjob.java:117)
at b4a.example.main._button1_click(main.java:448)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:2408)
at android.view.View$PerformClick.run(View.java:8816)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

This link http://192.168.1.4/desktop/login.php is you problem.

your problem may be that the php file is on the desktop, if you are using it locally you must use a local server, for example xampp, and place the file inside the htdocs folder, the response time is exhausted because php does not It runs being on the desk.
 
Upvote 0
Top