I'm using Mysql connection over SSH between my xdataserver and my database.
As i'm using http request from fnc web, i'm afraid to lose the ssh connection on server.
My question is :
Is it better to open and close ssh tunnel and FdConnection for each request or just keep my connection on and test if still connected ?
Thanks in advance.
I fail to see the relation between FNC Web request and your question?
In any case, I think this is more a FireDAC question than XData. Can FD works well with a shared tunnel, or does it need to be used by each connection? Is the tunnel and connection 1:1 relation, or can you reuse a tunnel in multiple connections? I don't know.
For simple db connections, one should be used in each request. That's why we provide a connection pool, which guarantees that one connection is used per request, but at the same time you don't need to create and destroy one connection in each request, but instead use one from the pool which is already connected.
Possibly you can do the same with tunneled connections?
Thank you for your response.
Ok for ssh.
I have only one FdConnection.
I have a datamodule that contain Fdconnection et Ssh tunnel.
For each service (for example getEvents):
i have to use myFdconnection or the pooled connection ?
How can i use it ?
I don't know if
TFDConnection is thread-safe, not thread-safe, or if its thread-safety depends on some configuration. To be sure, maybe you can ask in proper FireDAC support channels.
For my own code, I always use one different TFDConnection per request to be on the safe side (to be more precise, one IDBConnection per request).
To use XData/Aurelius pool, you should configure a TAureliusConnection component according to Database Connectivity | TMS Aurelius documentation
Then just drop TXDataConnectionPool component and associate it to the Aurelius connection.