Standalone not connecting to mySQL

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Standalone not connecting to mySQL

Post 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?
Kaveh
AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: Standalone not connecting to mySQL

Post 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
Andy .... LC CLASSIC ROCKS!
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Standalone not connecting to mySQL

Post 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
Kaveh
AndyP
Posts: 634
Joined: Wed Aug 27, 2008 12:57 pm
Contact:

Re: Standalone not connecting to mySQL

Post by AndyP »

Yes should have been HTTPD not HTTP..sorry

Do you get the same problems if you automatically select inclusions?
Andy .... LC CLASSIC ROCKS!
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Standalone not connecting to mySQL

Post 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...
Kaveh
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Standalone not connecting to mySQL

Post 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Standalone not connecting to mySQL

Post 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.
Kaveh
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Standalone not connecting to mySQL

Post 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Standalone not connecting to mySQL

Post 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...
Kaveh
SparkOut
Posts: 2984
Joined: Sun Sep 23, 2007 4:58 pm

Re: Standalone not connecting to mySQL

Post 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.
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Standalone not connecting to mySQL

Post by kaveh1000 »

Thank you SparkOut. I cannot ignore your passionate plea!! I will work on a better method of access... ;-)
Kaveh
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Standalone not connecting to mySQL

Post 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
Kaveh
sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Standalone not connecting to mySQL

Post 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
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 539
Joined: Sun Dec 18, 2011 7:23 pm
Contact:

Re: Standalone not connecting to mySQL

Post 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
Kaveh
sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Standalone not connecting to mySQL

Post by sphere »

No worries mate!
i make myself the most stupid things too :lol: (is that good english?)
Post Reply