Sequoia connecting to MYSQL-Database

I’am trying to connect to a MySQL database using the MySqlCommunityServer etc, etc.
When I build the program and then Run it it works fine.
However when I try to run and debug it, then the connection fales.
On Sonoma both ways work fine.

This is the third time I switched to Sequoia and thougt the problem must be solved by now.
Who has a solution for this problem or perhaps a workaround or do I have to stick with Sonoma?

Any error messages you see?

It this a MySQLServer in the local network or a server in the internet?
If local you may miss a new entitlement to access local network…

Error Message 65 (can’t connect to MySQL Server on "192…

On the local network and it always worked until the update to Sequoia..

Its a new security feature in Sequoia:

I tried to read this, but this is beyond my knowledge.

Perhaps I will install a testing DataBase on my coding computer.
Than I have access to this testing DataBase when debugging without any problem.
In case of Building the program, I will connect to the local server.

e.g.
If DebugBuild Then

mDB.Host = “127…”
mDB.DatabaseName = “Xojo”

Else

mDB.Host = “192…”
mDB.DatabaseName = “Any”

End If

But will this be future-proof???

You need to add an entitlement to the info.plist file of your app. Something like this:

	<key>NSLocalNetworkUsageDescription</key>
	<string>Verbindung mit einem (lokalen) Datenbankserver aufnehmen. Connect to a (local) database server.</string>

And it would be a good idea to keep in mind that your first connection attempt may be blocked by macOS, asking the user to confirm local network access…

2 Likes

I tried to insert that in the property list of the program, but it did not work.
The question box asked to trust the connection, but after that the database was not connected
even after 10 trials.

Does your program try to establish the connection every time it starts (in an opening event)? If so, try to establish the connection manually. E.g. with a button - after the program is already running in debug mode.

Yes, the connection starts in the opening event of the App.
I tried it in the pressed event of a Button, but no connection.

Do you have any build scripts that are set to run on release but not debug builds that might be changing things?

No, just a strait testing program.
I think that the Xojo people should look at it, because it only occurs with Run (and Debug).

The only working solution for now is to install a DataBase on the coding computer for testing.

Thanks anyhow for helping.

I had this exact same problem. Database connections stopped opening in Sequoia. I put in both “NSLocalNetworkUsageDescription” and “NSNearbyInteractionUsageDescription” into the app’s plist, but that didn’t have any effect. Same symptom in both debugger and built app.

The only way I solved it was a terrible kludge, which is to open the database, and if that opening fails, I show a modal dialog that just says “Click OK to continue.” When that dialog is dismissed by the user, I try opening the database again, and that time it works.

I’m guessing that this gives the system time to check the entitlements after the first database open attempt.

I suppose I could use a timer instead of a dialog, but then I’d have to put the database class into a thread which would mean a lot of refactoring.

This really is a dumb workaround and I’m hoping someone can point me at a better solution.

PS: even though I’m hardly ever active on this forum these days, I still think Xojo is a fantastic solution and I use it whenever possible for my hobby projects.

This makes it sound like the local-connections “security” measure Apple added. Apps aren’t able to make network connections for a few seconds after launch and no one knows why. This “alert the user and retry” method is the only thing that works.

I deal with it daily in Lifeboat since my debug server is a local Pi. Every single launch the auto connect fails. Occasionally, my production instance fails the first local attempt even though it’s not automatic (app launches, window shows, I manually connect to a server).

I don’t have any better suggestions. Alert + retry is what I do.

I think this is a related discussion. Maybe it can help alleviate some pain while doing dev work.

It doesn’t seem like a great solution to recommend to one’s software customers…