2 views
Skip to first unread message

戚金奎

unread,
Nov 29, 2024, 2:26:47 AM11/29/24
to firebi...@googlegroups.com
Issue Title:
Unable to Connect to Firebird using Jaybird JDBC with SOCKS5 Proxy: SQLNonTransientConnectionException (Jaybird v5.0.6, Firebird 2.5.6)

Issue Description:
I am facing an issue when trying to connect to a Firebird database using the Jaybird JDBC driver (version 5.0.6 for Java 8) with a SOCKS5 proxy. The connection works fine when connecting directly to the database without using the proxy, but when I attempt to use the SOCKS5 proxy, I get 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)
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)));
}
JDBC URL: I am using the following JDBC URL to connect to Firebird:

java
Copy code
String url = "jdbc:firebirdsql://localhost:3050/your_database.fdb";
Proxy Configuration: The proxy configuration for the connection is set as follows:

Error on Connection: When the proxy is enabled, I receive the above exception during the connection attempt.

Expected Behavior:
The connection should succeed when using the SOCKS5 proxy, similar to the behavior when connecting directly to Firebird without using a proxy.
Actual Behavior:
The connection fails with the error SQLNonTransientConnectionException: Unable to complete network request to host "localhost", which is related to the socketConnect method in WireConnection.java.
Environment:
Jaybird Version: 5.0.6 (Java 8)
Firebird Version: 2.5.6
Java Version: [e.g., Java 8]
Operating System: [e.g., Windows 10 / Ubuntu 20.04]
SOCKS5 Proxy: Local SOCKS5 proxy running via Docker with image: xkuma/socks5
Additional Information:
I have verified that the SOCKS5 proxy is working correctly by using it for other services (e.g., HTTP).
The direct connection to Firebird works without issues (without using the proxy).
Firewall/Network Settings: There are no known firewalls or network restrictions blocking connections to the Firebird database or the SOCKS proxy.
Logs/Stack Trace:
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)
What I Expect from the Issue:
I would appreciate it if someone could investigate why the connection fails when using the SOCKS5 proxy and if there are any necessary adjustments or configurations needed within the Jaybird driver to support SOCKS5 proxies for Firebird connections.

Thank you!

Mark Rotteveel

unread,
Nov 29, 2024, 2:38:13 AM11/29/24
to firebi...@googlegroups.com
As you also reported it on
https://github.com/FirebirdSQL/jaybird/issues/826, I'll reply there.

Mark
> --
> You received this message because you are subscribed to the Google
> Groups "firebird-java" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to firebird-jav...@googlegroups.com <mailto:firebird-
> java+uns...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/
> firebird-java/
> CAByumAXFLrzfCpcTJk3hsON0evbf3CCkmRwm1r4szTxTtsq94g%40mail.gmail.com
> <https://groups.google.com/d/msgid/firebird-java/
> CAByumAXFLrzfCpcTJk3hsON0evbf3CCkmRwm1r4szTxTtsq94g%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.


--
Mark Rotteveel
Reply all
Reply to author
Forward
0 new messages