Usually when a client needs to connect to server it is assumed that a direct connection can be established. Nowadays though, due to security reasons or network topology, it is often necessary to use a proxy or bypass a firewall. This article describes different ways to connect to server with dotConnect for PostgreSQL.
Direct connection to server means that server host is accessible from client without extra routing and forwarding. This is the simplest case. The only network setting you need is Host parameter of connection string. This is also the fastest and most reliable way of communicating with server. Use it whenever possible.
The following lines illustrate the simplicity:
Sometimes it is necessary to connect to server in another network. For example, client address is 10.0.0.2, server address is 192.168.0.10. The client and server reside in different networks, so the client can reach it only through proxy at address 10.0.0.1, which listens on port 808. In this case in addition to connection string parameter Host you have to setup PgSqlConnection.ProxyOptions object as follows:
Note that setting parameters of PgSqlConnection.ProxyOptions automatically enables use of proxy server. Connections through proxy are available when PgSqlConnection.Protocol property is Tcp (default) or Http.
As usual, you can specify all settings in connection string:
Port=3307;Proxy Host=10.0.0.1;Proxy Port=808;Proxy User=ProxyUser;Proxy Password=ProxyPassword;User ID=postgres;Password=postgres;Host=192.168.0.10;
Keep in mind that traffic tunneling or encryption always increases CPU usage and network load. It is recommended that you use direct connection whenever possible.