User cannot get internet connection

My app connects to YouTube. I have this code in to test if the user has access to the internet so it can work. One user is getting this “Error code: 0” despite having a valid internet connection. He is running Windows 10. I had him check his firewall settings and he did so and said he had no virus protection including Windows Defender (yikes), so I’m wondering why he might be getting this error? Works fine for others.

[code] data = socket1.Get(newURL, 30)

if data <> “” then
// user has an internet connection
else
if socket1.lastErrorCode <> 0 then
msgBox "Error code: “+ str(socket1.ErrorCode)+ " - A connection to YouTube was not able to be established. Check your internet connection and try again.”
return
end if
end if[/code]

Is there a better way of checking? Got the code from a search. I could try commenting that out and seeing if it runs for him. May be returning a false positive?

What is socket1 defined as?

I assume you’re using HTTPSocket?

Just looking at it, checking lastErrorCode then reporting ErrorCode probably isnt the best idea.

Personally I would read ErrorCode on the if and the msgbox as ErrorCode provides additional information.

He might be in a location that has youtube blocked, however I would expect some data to be returned but it might be timing out and not being caught by your msgbox because of the above post.

Also, are you listening for HTTPSocket.ProxyAuthenticationRequired ?

It might be coming back with that and you’re ignoring it so it might not be getting anywhere.

YouTube might be rejecting HTTP 1.0 requests
YouTube might also be rejecting the connection if it’s not over HTTPS.

Use the new framework Xojo.Net.HTTPSocket - you might have more success.

Check if the error code is < 1 but > -1, seeing as you seem to be getting a case of zero is not zero.