hi, in my stack i connect automatically when open a card named "database" to a database, but after a little time the connection is lost, any ideas on how to not lose the connection as long as the user is in the card "database" ?
thanks!
lost connection
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 40
- Joined: Sun Dec 13, 2015 6:05 pm
Re: lost connection
This can be caused by aggressive server handling of socket timeout, to workaround this you could call this command each time you call database related functions:
Code: Select all
local sDatabaseID
command ensureDatabseConnection
local tOpenDatabases
put revOpenDatabases() into tOpenDatabases
if sDatabaseID is among the items of tOpenDatabases and sDatabaseID>0 then
exit ensureDatabseConnection
end if
put revOpenDatabase("mysql", "hostAddress", "yourDatabaseName", "YourUserName","YourPassWord",,,0, true) into sDatabaseID
end ensureDatabseConnection