Is there a simple test for internet connectivity? #12121
Unanswered
kjm1102
asked this question in
Using MicroPython
Replies: 3 comments 2 replies
-
This is what I use in my modified version of umail: try:
addr = usocket.getaddrinfo(host, port)[0][-1]
break
except OSError as err:
if err.args[0] == -202: # no network available
with open('errors.txt', 'a') as outfile:
outfile.write('no network available' + '\n') |
Beta Was this translation helpful? Give feedback.
0 replies
-
Tnx Dave, looks like -202 is the one to trap.
…On Sun, 30 July 2023, 7:56 pm Dave Festing, ***@***.***> wrote:
This is what I use in my modified version of umail:
try:
addr = usocket.getaddrinfo(host, port)[0][-1]
break
except OSError as err:
if err.args[0] == -202: # no network available
try:
with open('errors.txt', 'a') as outfile:
outfile.write('no network available' + '\n')
except OSError:
pass
—
Reply to this email directly, view it on GitHub
<#12121 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV562MYBMHMNE2KDXMXLCKTXSYVTXANCNFSM6AAAAAA25BWSTU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I have used this approach - sending a DNS lookup for "google.com" to 8.8.8.8 (a Google DNS server). The advantage is that the implemantation is nonblocking - |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been using sta.status('rssi') in the mistaken belief that an ip address in the return meant I have internet. However I just got ss -29 ('192.168.4.2', '255.255.255.0', '192.168.4.1', '192.168.4.1') from an AP that does NOT have internet so I'm wondering if there is something simpler than a ping that I can use to indicate internet availability?
Beta Was this translation helpful? Give feedback.
All reactions