Android Question HTTPJob.PostString Auth

worksoft.marco

Member
Licensed User
Longtime User
Greetings

Has anything changed in the library HttpUtils2 in version 3.00??

In the previous version, the authentication with PostString worked perfectly (following example code):

B4X:
Dim Job As HttpJob              
  
Job.Initialize("Cidades", Me)
Job.Username = usuario
Job.Password = senha
Job.PostString("http://" & endereco & "/datasnap/rest/TServerMethods1/baixaCidades", idemp)

Now, I can not authenticate to the webservice, I made a debug in the webservice and username and password are coming blank.

If you changed the way of authenticating, would like some tips accordingly.

Thanks in advance.
 

worksoft.marco

Member
Licensed User
Longtime User
Sorry for the insistence, but I'm out of ideas to continue.

Is there another way to debug the error, for example, debug the httputils2 routine?

Or another line of reasoning, what could affect authentication?

Thanks in advance.
 
Upvote 0

worksoft.marco

Member
Licensed User
Longtime User
Greetings

I made some tests, but not working yet.

What I did:
- Updated the android development libraries;
- Reinstalled basic4android;
- Tried with other servers;

I do not know if it helps, but here is the debug when I get the unauthorized message from server:

B4X:
** Activity (sincronizacao) Create, isFirst = true **
** Activity (sincronizacao) Resume **
startService: class anywheresoftware.b4a.samples.httputils2.httputils2service
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Failed to read error message.
** Activity (sincronizacao) Pause, UserClosed = true **

Would like an opinion on what else I could debug to determine the problem.

Thanks in advance.
 
Upvote 0

worksoft.marco

Member
Licensed User
Longtime User
Yes, I tried on other servers.

Here the unfiltered logs.

B4X:
** Activity (sincronizacao) Create, isFirst = true **
** Activity (sincronizacao) Create, isFirst = true **
false true
false true
** Activity (sincronizacao) Resume **
** Activity (sincronizacao) Resume **
Displayed com.worksoft.vendasmobile/.sincronizacao: +250ms
AudioStreamOutMSM7x30::standby()
Deroute pcm out stream
updateDeviceInfo: E rx_device 2 and tx_device 3
No active voicecall/playback, disabling cur_rx 2
value of device and enable is 2 0 ALSA dev id:15
No active voicecall/recording, disabling cur_tx 3
value of device and enable is 3 0 ALSA dev id:12
updateDeviceInfo: X cur_rx 2 cur_tx 3
value of device and enable is 2 1 ALSA dev id:15
startService: class anywheresoftware.b4a.samples.httputils2.httputils2service
startService: class anywheresoftware.b4a.samples.httputils2.httputils2service
** Service (httputils2service) Create **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
msm_route_stream(PCM_PLAY,5,15,1)
Authentication error: Unable to respond to any of these challenges: {}
java.net.SocketException: Socket closed
    at libcore.io.Posix.recvfromBytes(Native Method)
    at libcore.io.Posix.recvfrom(Posix.java:131)
    at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:164)
    at libcore.io.IoBridge.recvfrom(IoBridge.java:513)
    at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488)
    at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
    at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:134)
    at org.apache.http.impl.io.IdentityInputStream.read(IdentityInputStream.java:86)
    at java.io.InputStream.read(InputStream.java:163)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:178)
    at org.apache.http.util.EntityUtils.toByteArray(EntityUtils.java:79)
    at anywheresoftware.b4a.http.HttpClientWrapper$ExecuteHelper.run(HttpClientWrapper.java:286)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    at java.lang.Thread.run(Thread.java:856)
Failed to read error message.
Failed to read error message.
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@2b8cf7e0 attribute=null
No longer want com.google.android.partnersetup (pid 4348): hidden #11
AudioStreamOutMSM7x30::standby()
Deroute pcm out stream
updateDeviceInfo: E rx_device 2 and tx_device 3
No active voicecall/playback, disabling cur_rx 2
value of device and enable is 2 0 ALSA dev id:15
No active voicecall/recording, disabling cur_tx 3
value of device and enable is 3 0 ALSA dev id:12
updateDeviceInfo: X cur_rx 2 cur_tx 3
GC_FOR_ALLOC freed 6345K, 73% free 5626K/20807K, paused 79ms, total 82ms
GC_CONCURRENT freed 3586K, 46% free 10615K/19463K, paused 3ms+6ms, total 114ms
** Activity (sincronizacao) Pause, UserClosed = false **
** Activity (sincronizacao) Pause, UserClosed = false **
enable(false)
About to give-up screen, flinger = 0xfb88
Set visibility on com.android.internal.policy.impl.LockPatternKeyguardView$5@2bd44f90 to 8388608
portrait mode
Create TCV com.android.internal.widget.TransportControlView@2b8d2300
KGVM: Set visibility on com.android.internal.policy.impl.KeyguardViewManager$KeyguardViewHost@2bc227c8 to 6291456
Start proc com.google.android.gsf.login for service com.google.android.gsf.login/com.google.android.gsf.loginservice.GoogleLoginService: pid=4825 uid=10059 gids={3003, 1015, 1028, 1007, 1006, 2001, 3006}
disable: < EXPAND* icons alerts TICKER* system_info back home RECENT* clock >
Set visibility on com.android.internal.policy.impl.LockPatternKeyguardView$5@2bd44f90 to 8388608
disable: < EXPAND icons alerts TICKER system_info BACK* HOME* RECENT CLOCK* >
GC_CONCURRENT freed 1471K, 43% free 11248K/19463K, paused 5ms+8ms, total 107ms
WAIT_FOR_CONCURRENT_GC blocked 86ms
WAIT_FOR_CONCURRENT_GC blocked 91ms
WAIT_FOR_CONCURRENT_GC blocked 67ms
Set visibility on com.android.internal.policy.impl.LockPatternKeyguardView$5@2bd44f90 to 8388608
No longer want com.tmobile.thememanager (pid 4530): hidden #11
 
Upvote 0

worksoft.marco

Member
Licensed User
Longtime User
Erel

I turned back to version 2.71 and the authentication worked fine.

The server is written in Delphi 2010 (Datasnap + JSON) and has not changed.

Any more information I can provide to resolve this issue?

For now I'll keep using the version 2.71

Thanks in advance.
 
Upvote 0

worksoft.marco

Member
Licensed User
Longtime User
Erel

I installed b4a 3.00 on a new machine to test if it could be some issue related to the upgrade.

However, the result was the same, I can not authenticate with version 3.00 on the new machine,
but with version 2.71 on the old machine, everything works perfectly.

If there is any more information I can provide, I'm available to help.

Thanks.
 
Upvote 0

pgoodwin

New Member
Licensed User
Longtime User
I have this exact same issue, v. 2.71 works flawlessly. Anything higher and I get an unauthorized back. Using digest authentication on the server.
 
Upvote 0

pgoodwin

New Member
Licensed User
Longtime User
Unfortunately it is not a public server.
The server logs do show differences between the 2 versions eg.

#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
B4a v 2.71
2014-01-21 13:48:43 0.0.0.0 GET /api/APICALL - 15 - 0.0.0.41 - 401 0 0 4
2014-01-21 13:48:43 0.0.0.0 GET /api/APICALL - 15 USERNAME 0.0.0.41 - 200 0 0 45

As you can see the original get request bounces back as unauthorized and B4A responds as per digest rules and the call is returned OK

B4a v. 3.20
2014-01-21 17:37:02 0.0.0.0 GET /api/APICALL - 15 - 0.0.0.41 - 401 0 0 12
2014-01-21 17:37:02 0.0.0.0 GET /api/APICALL - 15 - 0.0.0.41 - 401 1 2148074255 7

In the new versions the original unauthorized call is there, however the second call that should be passing the USERNAME credential does not have it.

*Note IPAddresses, USERNAME, APICALL and PORT have been changed to imaginary values
 
Upvote 0

worksoft.marco

Member
Licensed User
Longtime User
Erel

After a long time, I decided to upgrade to version 5, but the issue related on this thread remains.

A public server is available for testing, follow the data for access and a example:

Sub Baixar
Dim Job As HttpJob
Dim idemp as string

idemp = "{" & Chr(34) & "empresa" & Chr(34) & ":" & Chr(34) & "01" & Chr(34) & "," & _
Chr(34) & "filial" & Chr(34) & ":" & Chr(34) & "01" & Chr(34) & "," & _
Chr(34) & "vendedor" & Chr(34) & ":" & Chr(34) & "MELVI" & Chr(34) & "," & _
Chr(34) & "senha" & Chr(34) & ":" & Chr(34) & "123" & Chr(34) & "}"

Job.Initialize("CondPagto", Me)
Job.Username = "b4a"
Job.Password = "b4atest"
Job.PostString("http://201.68.9.219:8090/datasnap/rest/TServerMethods1/baixaCondPagto", idemp)
end sub

Thanks for now.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…