Android Question OkHttpUtils2 v3.02 issue when POSTing / PUTing

dazwin788

Member
Licensed User
Hi all,

(Apologies if I'm posting this in the wrong place- I don't post very often!)

I updated the OkHttpUtils2 internal library in B4A to v3.02 yesterday and immediately noticed some of the POSTs / PUTs in my code are timing out with a socket exception where it was fine with v3.01. As as example of code I am using:

B4X:
Dim j As HttpJob
    
j.Initialize("", Me)

j.Username = "XXXXX"
j.Password = "XXXXX"

j.PostString(ServerUrl, Json.ToString)
    
Wait For (j) JobDone(j As HttpJob)
    
Dim Success As Boolean = ProcessServerResponse(j)
        
j.Release

GETs / downloads are fine.

Switching back to v3.01 resolves the problem instantly. After a bit of investigation, it would seem that I can circumvent the problem by explicitly setting the content-type header (probably good practice anyway):

B4X:
j.GetRequest.SetContentType("application/json")

This isn't the end of the world, but it does break some of my legacy code where the content-type isn't set. Also I am concerned there may also be other issues with this version if this is just a symptom of another problem. Has anyone else noticed this issue, or am I doing something wrong?

As I say, v3.01 works flawlessly.

Thanks in advance!
 

dazwin788

Member
Licensed User
Just strange that swapping back to v3.01 (without any changes to the code at all) addresses the issue. I may be able to provide some test code/app and a server script to demonstrate but I would be reluctant to post our server URL etc on a public forum.

If content-type is required to avoid a timeout then really it should be a param in the put and post subs?
 
Upvote 0
Top