Android Question okhttputils not working on some devices

Qolam

Member
hello
ive tried many ways but keep seeing this :
ResponseError. Reason: javax.net.ssl.SSLHandshakeException: Handshake failed
it works fine when i run it on bluestacks
but not on two phones (android 7 and 9 )

i am doing the code like this :
code:
    Dim job As HttpJob
    job.Initialize("", Me)
    job.Download(Url)
    job.Download2(Url, Array As String( "key1","value1"))
 
    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        Log("success")
        Dim pageContent As String = job.GetString ' Get the web page content as a string


ive added the
AddPermission(android.permission.INTERNET)
to manifest but no luck there.
i checked the list permissions
the
service reciever has only permission of :
android.permission.FOREGROUND_SERVICE

but all else have internet permission. what should i do ?

the host im trying to get data from uses these protocols :
Protocols
TLS 1.3Yes
TLS 1.2Yes*
TLS 1.1No
TLS 1.0No
SSL 3No
SSL 2No

how do i make it work?
thanks for ur help
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
AddPermission(android.permission.INTERNET)
to manifest but no luck there.
i checked the list permissions
the
service reciever has only permission of :
android.permission.FOREGROUND_SERVICE
All of this has nothing to do with the error.

Most probably a misconfigured server. If you can post the link then please do.
Making the device accept all certificates might workaround this error: https://www.b4x.com/android/forum/threads/110673/#content
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Search for "NetworkClearText"
 
Last edited:
Upvote 0

Qolam

Member
All of this has nothing to do with the error.

Most probably a misconfigured server. If you can post the link then please do.
Making the device accept all certificates might workaround this error: https://www.b4x.com/android/forum/threads/110673/#content
im trying to get the data from

it returns a simple string and it works on browser + python code that i gave it these :
Python:
try:
        # Define headers to mimic a browser request
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
            "Referer": "https://cafcode.ir/",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            "Accept-Language": "en-US,en;q=0.9",
            "Accept-Encoding": "gzip, deflate, br",
            "Connection": "keep-alive",
            "Cache-Control": "max-age=0",
        }
        print("0")
        # Fetch the webpage content with headers
        print(f"Fetching URL: {url}")
        response = requests.get(url, headers=headers, verify=False)  # Disable SSL verification
    except Exception as e:
        print(f"Error: {e}")

when i do this it gets the data.

i also did the ctr+b
and inserted the two codes u gave me
still returns the ssl error:
ResponseError. Reason: javax.net.ssl.SSLHandshakeException: Handshake failed
did this
HU2_ACCEPTALL

still the same.
 
Upvote 0
Top