Problem with web app sending data to cloud server

I created a web app to read electric submeters and send the data to a cloud server. It works fine when I run it in the debugger under Windows. When I compile and run it, it reads the meters OK, but does not write the data to the cloud server when running on the Raspberry Pi. Even worse, when running on a Beaglebone Black (which is available on the market now), it crashes when the code encounters
URLConnect = New URLConnection
just before sending the JSON string. URLConnect is a property of the app.

I copied the URL string to the clipboard and pasted it into FireFox and the server returned OK just as it should of and the data was saved in the server’s db so I know I was sending the right stuff. This code runs in the app while sessions are used for configuring the system and viewing meter readings. I am running Xojo 2022r1.

I am thinking there may be a Linux permission I have not set to allow communication with the outside server, but my knowledge of Linux is very limited. Any suggestions will be most appreciated.

Hi Dean, have you ran the remote debugger on the RPi itself and “seen” how it runs in the Linux environment? Assuming you have then perhaps some of the info in the debugger will give us a clue. You said it crashes about the time you instantiate a URLConnection… have you set a breakpoint there and reviewed the state of the objects you’re working with?

Looking back in my notes I see I commented my code with…

// UnsupportedOperationException <-- occurs when calling a URLConnection.Send() before last request is completed
// Err msg: 'A request is already in progress.'

…which I would have never caught if I didn’t remotely debug to the RPi platform. I’ll dig thru more of my notes. I have an RPi-based device that, similar to your submeters, reports it’s PV’s and other details back to a Web App (“Service”), where it also picks up new SP’s and other parameters that it applies during the course of the day. It was a huge learning curve but the final product is rock-solid.

1 Like

Using the remote debugger was a lot easier this time than several years ago when I tried it. I found a stupid error that kept the rPi from sending the message (I had commented out a line of code). The remote debugger also worked fine on the BeagleBone but with the same result as reported earlier. Everything executed perfectly up to the line

URLConnect = New URLConnection

Where it stopped saying “The application being debugged remotely has encountered a problem” and asks me to report it now. There are no other error messages and the debugger just says URLConnect is nil which is unchanged from start of the app.

I don’t know if I should file a bug report since Xojo says they support the rPi, but say nothing about BeagleBone. It sure would be nice if they did because no one seems to have stock of rPis since the pandemic. Perhaps I will roll it back to web API 1.0 and try a different type of connection.

So… remote debug the app but set it to not launch automatically. Once it gets there and the IDE is waiting for it to launch, launch the app from a terminal and get it to crash. You should get more helpful info in the terminal.

The BeagleBone runs a version of Debian with no graphical interface so everything is done in Terminal. When I run the app in the remote debugger, the terminal window shows that it is launching the app. I step through a couple break points and the Windows screen shows the application failed window without anything about the failure in the terminal window. When I look in the Linux system log, I see the entry I added to the app that says “Ready for URLConnection” that comes from the last line before the URLConnect = New URLConnection line. There are no further entries in the system log for nine minutes while it sat there until I went back into it to look at the log.

Then it must be simply hanging. Are you using Send or SendSync?

I am using SendSync, but it never gets that far. It always fails at the URLConnect = New URLConnection line. The system log on the following line that should show the JSON string does not execute.

var response As String
System.Log(System.LogLevelAlert, “Ready for new URLConnection”)
URLConnect = new URLConnection
System.Log(System.LogLevelAlert, Reading.ToString)
var url As String = “https://ezmeter.net/kwhuploader.php?Validate=h1U&4s9bd&MeterData=” + EncodeURLComponent(Reading.ToString)
System.Log(System.LogLevelAlert, URL)
response = URLConnect.SendSync(“GET”, url, 30)
System.Log(System.LogLevelAlert, "Response is " + response)

I created a new web app with three lines of code in the App.Opening with a breakpoint on the second line.

System.Log(System.LogLevelAlert, “URLConnectionTester starting”)
URLConn = new URLConnection
System.Log(System.LogLevelAlert, “It worked”)

When I stepped through the second line, I got the familiar error message. There was nothing in the terminal window after “Launching DebugURLConnectionTest”. Then when I stopped the app, the terminal printed:

Runtime error
Please report what caused this error along with the information below.
Common/ObjectGlue.cpp:147
Failure condition: mClassPtr
Xojo.Core.PlatformNotSupportedException

The first line only of the app was printed in the system log.

One clarifying question… are you running a Web App on the headless Beaglebones? And, is does this little headless Linux machine need to run it’s app as a Web App, or can you accomplish with a regular executable? And even further, can you install VNC client and use a local GUI app on that device for helping facilitate more debugging options?

Uh… a prerequisite is missing from that machine.

Make sure LibSoup 2.4 is installed.

Greg OTesters

Make sure LibSoup 2.4 is installed.

That solved the problem. Thank you Greg.

> William ReynoldsPro

One clarifying question… are you running a Web App on the headless Beaglebones? And, is does this little headless Linux machine need to run it’s app as a Web App, or can you accomplish with a regular executable? And even further, can you install VNC client and use a local GUI app on that device for helping facilitate more debugging options?

Yes, a web app is the best choice for this project. When complete the BeagleBone will sport a cape with a cell modem. The device will be mounted in an electrical enclosure with 1-10 electric submeters in a building where the owner has no physical (or internet) presence. If he needs to get into the system to reconfigure something, it will be much easier to do it over the internet using the web app than dragging a keyboard and monitor out to the site.

I may put VNC or TeamViewer on the device, but probably only for debugging during development. I still need to figure out how we will support this thing in the field if the cell modem isn’t working which I expect to be the biggest issue we might face.