1. Wayne Miller
  2. PowerBuilder
  3. Thursday, 3 October 2019 16:16 PM UTC

We currently have an old power builder app (version 6 I believe). This is an app that will be going away one all of our locations are on SAP so we do not want to rewrite it. It Is currently on a server with outlook 2010. Some of the out look patches have broken outlook so our power builder app is unable to send emails. We have tried moving our app to server 2008 r2 and the app does run but it errors out after 10 hours. We start it back up and it runs for 10 hours then cancels again. Have you seen something like this or could you think of what would be causing this. Any help would be greatly appreciated.

 

 

Michael Kramer Accepted Answer Pending Moderation
  1. Friday, 4 October 2019 01:28 AM UTC
  2. PowerBuilder
  3. # 1

I created solution for exactly this type of issue. I use the Timing object (new in PB 6!)

Solution is to keep DB connection alive by "pinging" DB at regular interval, but delay that ping if app is in the middle of another DB transaction.

Code sample #1: How to use my timing object

// App's instance variables
PRIVATE timer_DbKeepAlive inv_keepAlive

// App's Open event last line
// Keep SQLCA connection alive using default setup
inv_keepAlive = create timer_DbKeepAlive
inv_keepAlive.of_StartTimer(SQLCA)

// App's Close event
if IsValid(inv_keepAlive) then inv_keepAlive.Stop()

TIP: If you have more DB connections simply create more timer instances and start a timer for each connection.

 

Code sample #2: Class = timer_DbKeepAlive inherits from Timing

// *** *** *** *** INSTANCE VARIABLES
PRIVATE:
transaction itr_SQLCA // DB connection to keep alive

long il_checkInterval = 1800 // Default: 30 minutes
long il_dbRestoreCount

// Configurable "constants"
long MIN_CheckInterval = 60 // 1 minute
long MAX_RestoreCount  = 10
// -----------------------------------------------------------------------
// *** *** *** *** PUBLIC FUNCTION of_StartTimer(transaction atr_sqlca)
// Start "Keep Alive" for 
itr_SQLCA = atr_SQLCA
this.Start(il_checkInterval)
// -----------------------------------------------------------------------
// *** *** *** *** EVENT Timer( )
// Ping database (MSSQL syntax) to keep connection alive.
datetime ldt_now

SELECT GetDate() INTO :ldt_now FROM (SELECT 1 a) dummy USING itr_SQLCA;

if itr_SQLCA.SQLCode = 0 then
   this.of_LogStillAlive(ldt_now)

else
   // Connection dead despite keep alive signal
   il_dbRestoreCount ++
   if il_dbRestoreCount > MAX_RestoreCount then
      this.of_LogAbortTooManyFailures()
      HALT CLOSE // !!! ABORT !!!
   end if
	
   // Restore connection
   DISCONNECT USING itr_SQLCA;
   CONNECT USING itr_SQLCA;
	
   // Reduce interval to avoid repeated failure
   if il_checkInterval > MIN_CheckInterval then
      il_checkInterval /= 2
   else
      il_checkInterval = MIN_CheckInterval
   end if
   this.Start(il_checkInterval)
end if

 

Code sample #3: Utility function on class = timer_DbKeepAlive

Functions to set the MIN/MAX values and default interval. And function to LOG (here no action)

// *** *** *** *** PUBLIC FUNCTION of_SetRestoreCount(long al_maxRestoreCount)
MAX_RestoreCount = al_maxRestoreCount

// Sanity check: MAX >= 0
if MAX_RestoreCount < 0 then
	MAX_RestoreCount = 0
end if
// -----------------------------------------------------------------------
// *** *** *** *** PUBLIC FUNCTION of_SetCheckInterval(long al_initialInterval_seconds, long al_minimumInterval_seconds)
il_checkInterval = al_initialInterval_seconds
MIN_CheckInterval = al_minimumInterval_seconds

// Sanity check: MIN >= 15 seconds
if MIN_CheckInterval < 15 then
	MIN_CheckInterval = 15
end if

// Sanity check: Current >= MIN
if il_checkInterval < MIN_CheckInterval then
	il_checkInterval = MIN_CheckInterval
end if
// -----------------------------------------------------------------------
// *** *** *** *** PROTECTED FUNCTION of_LogStillAlive(datetime adt_AliveTimeStamp)
// LOG that DB connection is still alive at .
// . . .
// -----------------------------------------------------------------------
// *** *** *** *** PROTECTED FUNCTION of_LogAbortTooManyFailures( )
// LOG that app will abort due to too many DB reconnect attempts.
// . . .

Feel free to copy and adapt as needed. Ensure your global variables don't use same names as the instance variables.

Comment
There are no comments made yet.
Ronnie Po Accepted Answer Pending Moderation
  1. Thursday, 3 October 2019 21:31 PM UTC
  2. PowerBuilder
  3. # 2

It sounds like a connection timeout. I'd check the database connection settings. If you're using ODBC, the profile may have a timeout setting that you can modify.

Comment
There are no comments made yet.
Wayne Miller Accepted Answer Pending Moderation
  1. Thursday, 3 October 2019 20:08 PM UTC
  2. PowerBuilder
  3. # 3

i searched everywhere on the system and do not see anything about 10 hour limit

 

Comment
  1. mike S
  2. Thursday, 3 October 2019 20:24 PM UTC
bios?



don't look for 10 hours, look for anything about sleep or lower poewr type modes etc



  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Thursday, 3 October 2019 19:48 PM UTC
  2. PowerBuilder
  3. # 4

sounds like your system going into some sort of sleep/low power mode

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 3 October 2019 16:33 PM UTC
  2. PowerBuilder
  3. # 5

Hi Wayne;

   Well ... PB v6.x is a 20+ year old version of PB. So moving to newer O/S's & versions of Outlook would probably cause many issues with the App as the PB run-time (and generated code in the EXE) were never designed for related software versions that did not exist way back then.

Regards ... Chris

Comment
  1. Wayne Miller
  2. Thursday, 3 October 2019 16:36 PM UTC
That is what I was afraid. I just don't understand why it runs for 10 hours perfectly then get an error. The message is like it cannot connect to the database.
  1. Helpful
  1. Roland Smith
  2. Thursday, 3 October 2019 18:58 PM UTC
What is the database and how is the app connecting?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.