WGET$ IPIFY not working anymore

If doesn't fit into any other category ....
Post Reply
Hendrix
Posts: 33
Joined: Sun Feb 14, 2021 11:03 am
Has thanked: 9 times
Been thanked: 6 times

WGET$ IPIFY not working anymore

Post by Hendrix »

I have a module at a remote site sending me its external IP address once a day.
Lately, I just sends me messages "Connection Failed". Any idea what could be causing this?


' -- INIT --
EMAIL.SETUP "smtp.gmail.com", 465, "USER", "PASSWORD"

' -- MAIN --
do
a$= "External IP-address= " + WGET$("api.ipify.org/", 443)
r = EMAIL ("", "EMAIL_ADDRESS", "SUBJECT", A$)

select case r
case 0
print "Email fail."
case 1
print "Email success.",a$
case else
print "Email unknown."
end select

wait 20000
loop

RESULT:
Email success. External IP-address= Connection Failed
User avatar
Fernando Perez
Posts: 118
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 62 times
Been thanked: 67 times

Re: WGET$ IPIFY not working anymore

Post by Fernando Perez »

Hendrix, if it worked before and not now, it is because something will have changed on the server that your wget$ points to.
From Windows Power Shell ping "api.ipify.org" and you will see it change to "api.ipify.org.herokudns.com", with no response.

I advise you to change to another server, such as "ip.seeip.org" or even my domain's, "[External Link Removed for Guests]".

Code: [Local Link Removed for Guests]

url$ = "www.google.com"
gosub qPing

url$ = "ip.seeip.org"
gosub qPing
url$ = "https://ip.seeip.org/jsonip?"
result$ = wget$(url$)
a$ = json$(result$, "ip")
wlog "IP: "; a$

url$ = "www.myrapidq.it"
gosub qPing
url$ = "https://www.myrapidq.it/ip.php"
result$ = wget$(url$)
a$ = word.extract$(result$, "IP: ", "<")
wlog "IP: "; a$

url$ = "api.ipify.org"
gosub qPing
url$ = "https://api.ipify.org"
result$ = wget$(url$)
wlog result$

END

qPing:
  result = ping(url$)
  wlog "------------------------"
  wlog url$
  if result = 1 then wlog "Ping OK" else wlog "Ping fail"
return

Hendrix
Posts: 33
Joined: Sun Feb 14, 2021 11:03 am
Has thanked: 9 times
Been thanked: 6 times

Re: WGET$ IPIFY not working anymore

Post by Hendrix »

Thanks for solving my problem.
I now get this output:

------------------------
[External Link Removed for Guests]
Ping OK
------------------------
ip.seeip.org
Ping OK
IP: nn.nn.nn.nn
------------------------
[External Link Removed for Guests]
Ping OK
IP: nn.nn.nn.nn
------------------------
api.ipify.org
Ping fail
Connection Failed
Post Reply