Anyone else here experiencing web app failure / stopping after a short period of time?
Version 2023 release 1.1
OS: Windows 10 Pro
Anyone else here experiencing web app failure / stopping after a short period of time?
Version 2023 release 1.1
OS: Windows 10 Pro
Not here, but please define a short period of time.
One minute.
I am trying to use a SQLitePreparedStatement to add a user into a database and it seems like a silent failure might be happening. I’m going to log every step to try to find the problem.
Is it raising a database exception that’s not being handled?
If that bubbles to UnhandledException, that could terminate your app.
Not sure how I would be able to catch that. I thought I saw something a while back about prepared statements not working, there are multiple instances of prepared statements in my app and they all work correctly on searches but it seems that using one to execute (add a user) fails.
This is the code:
Var db As New SQLiteDatabase
Var dbfile As New FolderItem("data")
Var ps As SQLitePreparedStatement
Var n As String
Var o As String
Var p As String
Var e As String
n = Trim(wtname.Text)
o = Trim(wtuser.Text)
p = wtpass1.Text
e = Trim(wtemail.Text)
Var mb As MemoryBlock
mb = Crypto.Hash(p, Crypto.Algorithm.MD5)
Var cr As String = EncodeHex(mb)
p = cr
db.DatabaseFile = dbfile.Child("cmu0.sqlite")
wbc.Enabled = False
wbca.Enabled = False
wbx.Enabled = False
wtemail.Enabled = False
wtname.Enabled = False
wtpass1.Enabled = False
wtpass2.Enabled = False
wtuser.Enabled = False
uncheck_silent
passcheck_silent
namecheck_silent
emailcheck_silent
If wpfc = "pass" Then
Try
db.Connect
db.ExecuteSQL("BEGIN TRANSACTION")
ps = db.Prepare("INSERT INTO accounts (afullname, aname, apass, aemail, astatus, amulti, alimit, cbkg, ctext) VALUES(?, ?, ?, ?, 'start', 'N', 1, '&cffffff', '&c000000')")
ps.BindType(0, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(1, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(2, SQLitePreparedStatement.SQLITE_TEXT)
ps.BindType(3, SQLitePreparedStatement.SQLITE_TEXT)
// Session.ps.Bind(0, n)
// Session.ps.Bind(1, o)
// Session.ps.Bind(2, p)
// Session.ps.Bind(3, e)
ps.ExecuteSQL(n, o, p, e)
db.ExecuteSQL("COMMIT")
db.Close
Catch error As DatabaseException
MessageBox("DB Error: " + error.Message)
End Try
db.Close
resetall
hello.Show
wz.Text = "User account created."
Else
wz.Text = "Could not create user account."
End If
I’ve tried the code both with, and without, the bind.
I have no clue what I’m doing wrong, as this is my first time ever really trying prepared statements.
You can run a WebApp in the IDE / Debugger. Have you tried that?
That is how I have been running this… in the debugger.
Nothing pops up, not even a warning. This thing is silently crashing.
I even created a method to log unhandled exceptions and nothing shows up.
In the debugger, can you step through line-by-line and see where it’s dying?
So what do we know about the failure condition? I’ve got a lot of questions.
Are we sure this code is executing?
Does the failure happen when attached to the debugger?
(if so, is it pausing on the exception?)
Does the Close event fire?
Does the UnhandledException event fire?
Is it a hard crash?
If you need to, sprinkle your code with a lot of debug messages using Print(). The messages will appear in the debug messages panel and if / when you deploy with Lifeboat they will be logged so that you can access them (right click on the Web App → View Logs…)
Verbose logging is awesome. I discovered that some of my code was swapped around by logical mistake. I ended up making a separate logging method that detects if the app is in Debug run and prints comments.
The app is unstable, though, and keeps crashing. I think there’s a memory problem? I will have to keep testing it.
Not sure if that’s the problem because I’m no web expert but I have experienced the same thing when I would just run the app (on Linux). I ended up creating a service for the app and now it restarts every time.
I can barely even log in before it resets. Very frustrating and this means I cannot run SAAS, I’m going to have to go with SQL server remote plus desktop version and maybe phone apps.
I created an issue bc I think I recall at one point prepared statements were not working with one of the beta versions… I really don’t know.
My actual project file is enclosed in this Issue: https://tracker.xojo.com/xojoinc/xojo/-/issues/72608
Your code is almost unreadable.
Every property/variable is 1 to 3 letters. Looks like someone reverse engineering an obfuscated code.
Remove the SQL prepares. Do it directly using the current standards (selectsql).
https://documentation.xojo.com/api/databases/sqlitedatabase.html#sqlitedatabase-selectsql
And let’s see what will happen.
BTW, there are missing images in your uploaded code. Zip a complete package there.
Resolved.
Tim Parnell suggested that I place my data folder in one of the special folders outside of the build folder and IT WORKS.
For some reason unknown to me, a SQLite data store (even if it is intended to be only temporary) that is located in the build folder cannot be accessed by my executable if it is running on Linux or Xojo Cloud. Debug run does not have this limitation. My debug run has been executed on Windows 10 while the actual compiled app is running on a Linux production server and has been deployed to Xojo Cloud.
So I created a FolderItem property for the database location set at SpecialFolder.Documents and accessed the database that way.
The reason for choosing Documents is that ApplicationData special folder is not accessible on Xojo Cloud.
For clarification, visit SpecialFolder — Xojo documentation
And my app now works on both the production server and Xojo Cloud.
Xojo debug run is clearly different from running the compiled version.
Thank you to all who helped me solve this problem!