Android Question Http problem in 5g situation

Rosin

Member
Licensed User
Hey guys,here i am using the httpjob to get the cookie from my school's websit,but i have noticed that when i am using wifi,i send the get request,and it respond very quickly...but when i am using my 5g network instead of wifi...it will wait...wait until 30s(the timeout) though it maybe have already got the response,i set the timeout to be 1000ms...and it gives the respond in 1s....what is the problem??i am so confused...here is my code,any reply is appreciated,thank you
Sub nsmc_jiaowuxitong_login()
Dim http As HttpJob
http.Initialize("http", Me)
http.Download(url)
http.GetRequest.SetHeader("Connection", "keep-alive")
http.GetRequest.SetHeader("Cache-Control", "max-age=0")
http.GetRequest.SetHeader("sec-ch-ua", """Not.A/Brand"";v=\""8\"", \""Chromium\""v=\""114\"", \""Google Chrome\""v=\""114\""")
http.GetRequest.SetHeader("sec-ch-ua-mobile", "?0")
http.GetRequest.SetHeader("sec-ch-ua-platform", """Windows""")
http.GetRequest.SetHeader("Upgrade-Insecure-Requests", "1")
http.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36")
http.GetRequest.SetHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7")
http.GetRequest.SetHeader("Sec-Fetch-Site", "same-origin")
http.GetRequest.SetHeader("Sec-Fetch-Mode", "navigate")
http.GetRequest.SetHeader("Sec-Fetch-User", "?1")
http.GetRequest.SetHeader("Sec-Fetch-Dest", "document")
http.GetRequest.SetHeader("Referer", url2)
http.GetRequest.SetHeader("Accept-Encoding", "gzip, deflate, br")
http.GetRequest.SetHeader("Accept-Language", "zh-CN,zh;q=0.9")
http.GetRequest.Timeout = 1000 ’if i delete this...it will wait for 30s
Wait For (http) JobDone(http As HttpJob)
If http.Success Then
Dim headers = http.Response.GetHeaders As Map
Dim setcookie = headers.Get("set-cookie") As List
Dim jessionid = GetIDValue(setcookie.Get(0)) As String
Dim serverid = GetIDValue(setcookie.Get(1)) As String
Sleep(100)
MsgboxAsync(jessionid & "|" & serverid,1)
Else
Sleep(100)
MsgboxAsync("fail",1)
End If
http.Release
End Sub
 

Rosin

Member
Licensed User
Please use [code]code here...[/code] tags when posting code.

Job.Success will be false if the timeout is reached.
Are you sure that it always waits for the timeout value? This is not expected.

Thank you Erel,i am sure...it waits for 30s...but in wifi environment,it is a lot more fast
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
wifi is, by definition, different from cellular (5g or otherwise). for what it may be worth, i can
receive a response from your school very quickly over 5g, and i am some 12,000 kms away.

since i am not in your country, your school does not respond with the same data you are
looking for, but the response is quick. for obvious reasons, even i use my local network's
wifi, the actual connection to your school will not be via wifi. i assume when you say you
can connect via wifi, you mean over your school's local wifi network, which may actually
involve more than wifi, depending on the network's configuration and the size of your school.
if you are connecting from your home over wifi on your home network, the actual connection
to your school is not going to be wifi.

i notice in the response, some kind of challenge and a timeout. i did not bother with all your
http headers; perhaps there is an issue with one or more of them. what happens if you
connect without them? i notice you seem to have borrowed the headers directly from a
desktop browser's request. a desktop browser - if that's what you originally used to format
your request - may do more than a simple request with okhttputils. cutting and pasting may
be a problem.

in any case, there is no way for anyone other than someone on your school campus to
use wifi to connect with your school's server, so there is no way for anyway else to test
what you report. as for connecting over 5g, the response i received was very quick, just
like a normal okhttputils request.
 
Upvote 0
Top