iOS and MBS CubeSQL connection issues

Recently I was able to connect from an iOS app to CubeSQLServer by using recent MBS plugins.

But now, it just doesn’t want to work anymore. The same codesnippet works as expected when using it from a macOS app (code in Windows1 open event handler).

When I put the same snippet into the Screen1.Opening event handler of an iOS app, it fails to connect. I do not see any detailed information, when stepping through code in debugger.

Do you have any idea why this is no longer working for me?

Sub Opening() Handles Opening
  // use internal CubeSQL library
  Call InternalCubeSQLLibraryMBS.Use
  
  Dim db As New SQLDatabaseMBS
  
  db.Option("APPNAME") = "Xojo Test"
  db.Option("ConnectionTimeout") = "5" // 5 seconds timeout?
  db.Option("ConnectionEncryption") = "AES256" // or "AES192" or "AES256"
  
  db.DatabaseName = "cubesql:b790.ch@test"
  db.UserName = "tester"
  db.Password = "testpassword"
  
  If db.Connect Then 
    
    Dim r As RowSet = db.SelectSQL("select sqlite_version()")
    
    If r = Nil Or r.AfterLastRow Then
      TextArea1.Text =  "Failed to query version."
    Else
      TextArea1.Text =  "Version: "+r.ColumnAt(0).StringValue
    End If
    
  Else
    TextArea1.Text = "Could not connect to database"
    
  End If
  
End Sub

It’s probably not working for iOS or not loading.
Try this in iOS

if InternalCubeSQLLibraryMBS.Use then
MessageBox "Using internal CubeSQL library."
else
MessageBox "Failed, so please use library file."
end if

What does db.ErrorMessage say?

I run into that one, too.
Let me add an extra ErrorMessage property for iOS.

And you may catch exception and look into it’s reason property.

1 Like

The library is loaded:

1 Like

It looks like the db.Connect simply returns False and does not throw an exception

db.connect

it’s a function and a method!

I guess I misunderstood your writing: “And you may catch exception and look into it’s reason property.”

I found the culprit: Little Snitch Firewall. Once I stopped the network filter, then I was able to connect with the iOS app to cubeSQLServer on the internet and query it.

I was confused first, because the same code was operational from a macOS app.

Thanks to Christian for adding the error properties, when I saw the “connection timeout” message, I started to have an idea…

2 Likes
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.