Omnis PostgreSQL - Windows connection problem

Bastiaan Olij bastiaan at basenlily.me
Wed Dec 11 17:56:04 EST 2013


Hey Guys,

Little warning, I logged this as a bug, but at least for us on Studio 6,
any SQL error will change $connectstatus to no longer being OK, so while
there is nothing wrong with the connection, the code snipped below would
result in reconnecting the session.

I'm sure it will get fixed in no time.

Cheers,

Bas

On 12/12/13 12:20 AM, Bob Fiering wrote:
> Hi Andy,
>
> Added your code an forced a disconnect on the database backend to see if Omnis is rebuilding the connection.
> Works great. Only need some writing of extra error controls and user information but this is great.
> Thank you very much.
> One problem solved the javascript problem is the only thing that is left to solve.
>
>
> Best regards,
>
> Bob
>
> Op 10 dec. 2013, om 21:00 heeft Andy Hilton <andyh at totallybrilliant.com> het volgende geschreven:
>
> Yeah beats me why windows but that has been a long running question :)
>
> Let's say you have a session object called ioSessionObjRef - you can do things like this (we use this essentially before *every* call we make) :
>
> If ioSessionObjRef.$state.$cando
>    Do ioSessionObjRef.$state() Returns SessionState
>    If SessionState=kSessionStateLoggedOff
>        ;  OK message @DEBUG {You will need to reopen your application.}
>        ;  do what you need to do in this event
>    Else If SessionState=kSessionStateLoggedOn
>        ;  Test PostgreSQL a little further to make sure we really are connected.
>        Do ioSessionObjRef.$connectstatus() Returns ConnectStatus
>        If ConnectStatus<>kPgSqlConnectionOK
>            ;  check the error here before trying a reconnect - are we in the middle of a transaction ? If so give up and tell user to start again
>           Calculate SessionState as kSessionStateLoggedOff
>           Do $cinst.$reconnectSession() Returns FlagOK
>           If ioSessionObjRef.$state.$cando
>                 Do ioSessionObjRef.$state() Returns SessionState
>                 If SessionState=kSessionStateLoggedOff
>                     ;  OK message @DEBUG {You will need to reopen your application.}
>                     ;  do what you need to do in this event
>                End If
>            End If
>       End If
>    End If
> End If
>
>
> Where the method : $reconnectSession consists of :
>
> Calculate FlagOK as kTrue     ;; Default true.
> Calculate TransactionModeBegin as kSessionTranAutomatic     ;; Default automatic
> If ioSessionObjRef.$validref
>    ;  We have a valid session object.
>    Do ioSessionObjRef.$reset()
>    If ioSessionObjRef.$state=kSessionStateLoggedOn
>        Quit method kTrue
>    End If
>    ;  When reconnecting be sure that the $transactionmode does not get changed.
>    If ioSessionObjRef.$transactionmode.$cando
>        Do ioSessionObjRef.$transactionmode() Returns TransactionModeBegin
>    End If
> Else 
>    Calculate FlagOK as kFalse     ;; added 2013-03-30 to prevent timers reconnecting if a user has logged out - potential security flaw
> End If
> Quit method FlagOK
>
> As you will see the crux of all of this is calling the line :
> Do ioSessionObjRef.$reset()
>
> Try variations of the above (I have hastily pulled this out of my base classes so is not verbatim but hacked to fit so not guaranteed !!)
>
> Andy
>




More information about the omnisdev-en mailing list