Page 1 of 2

Standalone not connecting to mySQL

Posted: Tue Dec 04, 2018 8:38 pm
by kaveh1000
I have a stack that reads and writes correctly to a mySQL database, but a Mac Standalone created from it is not connecting. I have the following Inclusions checked in preferences:

mySQL
Database
SSL & Encryption


And I have included the following the following line in my stack to check for internet connectivity:

Code: Select all

put url "http://www.google.com" into tURL
   if tURL is empty then
      answer "Could not update preferences. Using local prefs"
      exit get_remote_prefs
   end if
and it fails to connect in this handler

Ideas pls?

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 9:11 am
by AndyP
Are you using a V8.XX community version?

I've noticed that in the HTTP inclusion is often not listed or included in some of the 8 versions, this applies to manual or automatic inclusion settings.

So I tested with 8.1.4 community and see the error using the following.

Code: Select all

on mouseUp
   put url "http://www.google.com" into tURL
   if tURL is empty then
      answer "Could not update preferences. Using local prefs"
      exit to top
   else
      answer "OK"
   end if
end mouseUp
Using Community 9.0.2 (rc2)
All works as expected.
If manually setting inclusions include the HTTP library

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 10:47 am
by kaveh1000
Hi Andy

I am using 9.0.2 (rc 2)

I am using manual inclusion, but can see only HTTPD library, not HTTP. Adding that one did not help. Should there be an HTTP library in the list of inclusions?

K

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 11:14 am
by AndyP
Yes should have been HTTPD not HTTP..sorry

Do you get the same problems if you automatically select inclusions?

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 1:52 pm
by kaveh1000
Interesting. With automatic settings, it gets past the fisrt stage, but gives me a different error:

Unable to connect to the database: revdberr, invalid database type

So the web connection is fine, but mySQL connection is not...

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 8:23 pm
by FourthWorld
Unless all connectivity to the DB is restricted to your local network, an HTTP-based API (RESTful or otherwise) is safer than directly exposing MySQL to the open Internet.

LiveCode Server can be used in such an intermediary role, as can Python, Perl, PHP, or nearly anything else you're comfortable with that can be run as a CGI under Apache.

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 8:28 pm
by kaveh1000
Thank you so much Richard. Point taken about security. But it is getting out of my comfort zone, so will have to consult colleagues about an API.

But for now, and before I release this to the world, it would be good to know how I can get this fixed. it is a test database anyway. So any pointers there would be great.

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 9:11 pm
by FourthWorld
This LiveCode Lesson provides guidance on connecting to a database from LiveCode Server:
http://lessons.livecode.com/m/4071/l/70 ... l-database

It's so rare that one would connect to a database over the open Internet that I'm not familiar with a lesson for that, but hopefully the details at that link will help there as well.

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 9:25 pm
by kaveh1000
Thanks Richard

Actually that was the procedure I followed and all is fine in the LiveCode app. But not connecting in standalone, although I have tried enabling all the right inclusions.

Thanks again and other opinions welcome.

In the meantime I will look into APIs...

Re: Standalone not connecting to mySQL

Posted: Wed Dec 05, 2018 9:52 pm
by SparkOut
Probably your ISP automatically blocks direct connection to the database from the internet, as it is such a terrible vulnerability. If you really MUST make direct connection (please, please only temporarily, just to confirm your database updates are ok) then check in your control panel. You will like have to specify the IP address of allowed connections, or (for the love of everything you hold dear, please don't) use a wildcard to permit connection from anywhere and everywhere by anyone and everyone.

Re: Standalone not connecting to mySQL

Posted: Thu Dec 06, 2018 7:54 pm
by kaveh1000
Thank you SparkOut. I cannot ignore your passionate plea!! I will work on a better method of access... ;-)

Re: Standalone not connecting to mySQL

Posted: Fri Feb 08, 2019 2:26 pm
by kaveh1000
Hi folks

Putting aside the security aspects that I have taken on board, I still want to solve the technical problem of why I cannot connect to a our MySQL database from a standalone, but I can from the IDE.

To recap, I have the following lines to test basic connection to the net, that I call on openstack:

Code: Select all

on get_remote_prefs
   put url "http://www.google.com" into tURL
   if tURL is empty then
      answer "Could not update preferences. Using local prefs"
      exit get_remote_prefs
   end if
end get_remote_prefs
If this succeeds, then I try to connect to a MySQL database. In Standalone settings, when I set LiveCode to search automatically for inclusions, the standalone gets past the code given above, i.e. no error message, but it gives error on connecting to the database:

Code: Select all

Invalid database type
In contrast, when I select inclusions manually, adding these:

HTTPD Library
MySQL
Database
SSL & Encryption
Answer Dialog
Ask Dialog


then the URL test gives an error, i.e. it cannot connect to the web site.

Any hints to proceed would be appreciated. In particular:
  • What am I failing to add in inclusions, that prevents the connection to www? I thought HTTPD would do it
  • If, as SparkOut suggested, the database (under our control) stops direct access from the internet, how come it allows connection from the IDE?
Grateful for any thoughts.

Kaveh

Re: Standalone not connecting to mySQL

Posted: Mon Feb 11, 2019 2:08 pm
by sphere
If it works in the IDE then if on the same computer it should also work with an standalone

did you also include Internet at the inclusions? just to make sure

Re: Standalone not connecting to mySQL

Posted: Mon Feb 11, 2019 2:23 pm
by kaveh1000
Oh my god. I did not!!! How embarrassing. Thank you so much Sphere for making me look a fool. ;-)

All working now. Thanks again. :-D

Re: Standalone not connecting to mySQL

Posted: Mon Feb 11, 2019 8:08 pm
by sphere
No worries mate!
i make myself the most stupid things too :lol: (is that good english?)