I am encountering an issue when trying to connect to a Firebird database using the Jaybird JDBC driver with a SOCKS5 proxy. The connection works fine when connecting directly to the database without using the proxy, but when I try to use the SOCKS5 proxy, I receive the following error:
Exception in thread "main" java.sql.SQLNonTransientConnectionException: Unable to complete network request to host "localhost". [SQLState:08006, ISC error code:335544721]
at org.firebirdsql.gds.ng.FbExceptionBuilder$Type$5.createSQLException(FbExceptionBuilder.java:677)
at org.firebirdsql.gds.ng.FbExceptionBuilder$ExceptionInformation.toSQLException(FbExceptionBuilder.java:571)
at org.firebirdsql.gds.ng.FbExceptionBuilder.toSQLException(FbExceptionBuilder.java:309)
at org.firebirdsql.gds.ng.wire.WireConnection.socketConnect(WireConnection.java:298)
Caused by: java.net.SocketException: SOCKS: Connection refused
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:564)
at java.net.Socket.connect(Socket.java:606)
at org.firebirdsql.gds.ng.wire.WireConnection.socketConnect(WireConnection.java:288)
Steps to Reproduce:
- Jaybird Version: I am using Jaybird 5.0.6 for Java 8.
- Firebird Version: I am connecting to Firebird 2.5.6.
- SOCKS5 Proxy: I am running a local SOCKS5 proxy via Docker from the following image:
Proxy Image: xkuma/socks5
- Custom Code in Jaybird: I have extended the WireConnection.java class to support SOCKS5 proxy connections. Specifically, I modified the socketConnect method to use a proxy if specified. Below is the relevant code I added to create a socket with the SOCKS5 proxy:
protected Socket createSocket() {
// Check if a proxy server is specified
String proxyServerName = dbAttachInfo.getProxyServerName();
if (proxyServerName == null || proxyServerName.isEmpty()) {
return new Socket(); // No proxy, create a regular socket
}
// Use SOCKS proxy
int proxyPortNumber = dbAttachInfo.getProxyPortNumber();
return new Socket(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(proxyServerName, proxyPortNumber)));
}
I am encountering an issue when trying to connect to a Firebird database using the Jaybird JDBC driver with a SOCKS5 proxy. The connection works fine when connecting directly to the database without using the proxy, but when I try to use the SOCKS5 proxy, I receive the following error:
Steps to Reproduce:
Proxy Image: xkuma/socks5