Do you see a response if you point your browser at that link?
Yes, with my browser i have an ipv6 adress
In Xojo i have a empty MessageBox. This API return IPv4 adress only.
you might want to consider ipify.org. They’ve got an api that supports both IPv4 and IPv6 and can return text, json or json
I have no idea what’s wrong, possibly your network config, I just tethered my surface to my phone and tested the ipv6 route via a browser and in code and it worked fine returning the ipv4 and ip6 addresses respectively using 2022r2 in Windows 11.
Just FYI www.ipify.org is blocked out of the box with pihole so if you are releasing anything to the public using that address, you might want to bear that in mind.
I kind of think it’s a bad idea to use an internet site to determine your IP address. In many and probably most corporate environments all you will get back is the external firewall address. You can get the local IP4 addresses just using System.NetworkInterface.
var MyAddresses As String
Var icount As Integer = System.NetworkInterfaceCount - 1
If icount >= 0 Then
Var iface As NetworkInterface
For idx As Integer = 0 To icount
// Get the NetworkInterface object for the selected item
MyAddresses = MyAddresses + System.NetworkInterface(idx).IPAddress
Next
End If
MessageBox(MyAddresses)
The OP asked for the public IP for whatever reason. Sometimes, using services like these are the only way due to network design, but yes, the public IP can be far from a unique identifier or anywhere near the physical site. YMMV
@LEROY_Daniel Try this:
var socket1 as new URLConnection
var pubip as String = socket1.SendSync("Get", "https://ipv6.icanhazip.com", 10)
Thanks @Gavin_Smith but i have this error message (why?):
Type “HTTPSocket” has no member named “SendSync”
Daniel
Because you didn’t copy all my code Note the change from the deprecated HTTPSocket class to URLConnection in my code. HTTPSocket has been deprecated since Xojo 2019r1. Here are the docs for URLConection, its replacement: URLConnection — Xojo documentation
Does it work for you now?
It works fine ! Thanks
Thanks too.