mainxt 1 Posted May 27 (edited) Hello everyone. I want to achieve connection restoration when the connection to the SQL server is lost. I use FireDAC and PostgreSQL, Delphi 11.3 CE. And there is a good working example for this: Recovering_Connection_(FireDAC), which completely satisfied me, if not for one problem. This example works well with a regular TFDConnection, but if there is an active TFDEventAlerter in conjunction with it, then the behavior becomes completely different... when choosing AAction := faOfflineAbort or faFail, the form freezes and stops responding. If all this is configured with TFDManager and AutoConnect:=True, then after 3 connection attempts, all connections are interrupted and we have to close the program - then we get an error - FDPhysManager shutdown timeout. Possible reason: application has not released all connection interfaces. If you disable TFDEventAlerter, all problems stop. Does anyone know any standard methods for dealing with this problem? It's strange that components and methods don't work with each other as they should. Edited May 27 by mainxt Share this post Link to post
weirdo12 21 Posted May 27 (edited) A TFDEventAlerter creates it's own new connection when you set the Connection property. So yes, you need to keep track of the TFDEventAlerter objects you create and disable them if the connection is lost. I found it necessary to set Active to false and clear the Connection property. Quote Set Connection to the component that establishes a connection to the DBMS. Because event alerter is using the connection in a background thread, it will use this connection as a template to create a new internal instance of connection to the DBMS. https://docwiki.embarcadero.com/Libraries/Athens/en/FireDAC.Comp.Client.TFDCustomEventAlerter.Connection Edited May 27 by weirdo12 1 Share this post Link to post
mainxt 1 Posted May 27 2 hours ago, weirdo12 said: A TFDEventAlerter creates it's own new connection when you set the Connection property. So yes, you need to keep track of the TFDEventAlerter objects you create and disable them if the connection is lost. I found it necessary to set Active to false and clear the Connection property. https://docwiki.embarcadero.com/Libraries/Athens/en/FireDAC.Comp.Client.TFDCustomEventAlerter.Connection Yes thank you. It really helped. I wrapped it in TTask.Run and it worked more responsively: if Assigned(FDEventAlerter.Connection) then TTask.Run( procedure begin FDEventAlerter.Connection := nil; end); 1 Share this post Link to post