Can't get rPi's IP address except with remote debugger

I use this code to get the Raspberry Pi’s IP addresses. It works in the remote debugger, but it doesn’t work when the program is compiled and run on the rPi. It is located in the app.open of a web app.

dim soc as new HTTPSecureSocket LanAddr = soc.LocalAddress IntIP = soc.Get("https://www.ezmeter.net/GetMyIP.php",10)
LanAddr and IntIP are string properties of the app and are uploaded to the cloud when the rPi syncs its data with the cloud.

What data do you get back when it’s built?

I don’t get anything back with the built version. It is supposed to write the data to a SQLite database that syncs with a cloud app that the user can access and get the IP address so he can access the app on his LAN. An empty field is written to the database for IntIP. 0,0,0.0 is written for LanIP.

I have a similar function on one of the web pages where I display the first three parts of the IP address so the user only needs the last value when configuring and Ethernet to RS485 adapter and that works. I am going to try URLConnection and xojo.net.HTTPSocket and see if one of those will work.

I could not figure out how to get the local address from URLConnection so I tried using it for the internet IP and switched to TCPSocket to get the local address. Again, it works fine in the remote debugger, but the same results from a compiled program running on an rPi. Libsoup 2.4 is installed.

I just open a shell and execute “ifconfig” and parse the results. Have you tried something like that?

Look at both eth0 and wlan0.

Looks like he Dean is looking for the Pi’s public IP, a quick workaround would be to use shell to curl the URL. Have you tried other types of sockets? HTTPSocket or Xojo.Net.HTTPSocket? Is this a desktop app or console app, how are you starting it ("./MyApp" or “/Path/To/MyApp”)

It appears the problem I am having only happens when the methods to get the IP addresses and sync with the cloud are called from app.open event when running as a compiled program. When called from a timer, a webpage in a session or the remote debugger, they work as expected. My solution is to start a timer in the app.open. Thanks for your suggestions.