This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 209287 - JDBC connection ignores proxy
Summary: JDBC connection ignores proxy
Status: RESOLVED INVALID
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.2
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Jiri Rechtacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-07 20:21 UTC by sirkorro
Modified: 2015-02-06 19:27 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
netbeans.exe -J-Dorg.netbeans.NbProxySelector.level=FINEST (96.02 KB, application/octet-stream)
2012-03-16 09:06 UTC, sirkorro
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sirkorro 2012-03-07 20:21:31 UTC
Even if i have proxy configured in NetBeans, Database (JDBC) connections from Services tab ignores it. JDBC is still connecting directly.
Comment 1 matthias42 2012-03-12 19:39:34 UTC
Can you please give a use case for this? I see reasons for creating ssh tunnels for connections (like accessing a remote mysql instance that only listens on a local interface), but why would you want to tunnel through a proxy?
Comment 2 sirkorro 2012-03-13 17:48:09 UTC
I'm developing something at work. For security reasons, my company use proxy for all kind of traffic. My DB is hosted in web. Now, it's impossible to connect such DB.
Comment 3 Jiri Rechtacek 2012-03-13 18:16:31 UTC
(In reply to comment #0)
> Even if i have proxy configured in NetBeans, Database (JDBC) connections from
> Services tab ignores it. JDBC is still connecting directly.

Please, run your IDE with a switch -J-Dorg.netbeans.NbProxySelector.level=FINEST for more verbose output of IDE, try connect your DB and then attach here messages.log from your userdir [1]. It helps figure out what's wrong. Thanks in advance

[1] wiki.netbeans.org/FaqWhatIsUserdir
Comment 4 sirkorro 2012-03-16 09:06:03 UTC
Created attachment 116786 [details]
netbeans.exe -J-Dorg.netbeans.NbProxySelector.level=FINEST

Two tries to connect to jdbc and one to update center.
Comment 5 matthias42 2012-03-16 20:23:13 UTC
Jugdeing from this:
INFO [org.netbeans.core.NbProxySelector]: Incomplete SOCKS Server [/] found in ProxySelector[Type: 2] for uri socket://api.antczak.org:3306. 
INFO [org.netbeans.modules.db.explorer.dlg.ConnectionPanel]: cannot establish a connection to jdbc:mysql://api.antczak.org:3306/krr_api using com.mysql.jdbc.Driver (Communications link failure

You did not specify a SOCKS-Proxy. Netbeans detects this in the NbProxySelector-Class (a ProxySelector is consulted to determine the proxy to use for certain Addresses) and reports "DIRECT_CONNECTION" as proxy. This obviously fails.

You have to set the SOCKS-Proxy - if you have only a HTTP-Proxy and specify to use that for this might or might not work. The socket connection itself is realised in native code, my short local test showed, that only a SOCKS-Connection is tried, so your proxy might (rightly) refuse the connection.

If the above fails you have to options:

1. Talk to you network people - if you need the connection for your work there should be a way (at our place for example only a selected group gets SSH permissions) and get a direct connection possibility.

2. If you have ssh access on the target machine use putty/ssh and port forwarding - I use that for a production system with mysql.
Comment 6 ogj 2014-12-11 12:55:03 UTC
I am also struggling with the "No proxy hosts" in Netbeans. 
This is v8.0.2 on Linux (Fedora 20 and 21) againts an Informix database.

All internet access needs to go through the company proxy, but the database servers are local, and can not go via the proxy.

I have a manual proxy setup, and a list of hosts (the database servers) that should not be proxied (tried with wildcards, with and without FQDN, makes no difference).

Without proxy setup the database access is just fine, but then other stuff does not work (like updates and such).

With the proxy setup enabled 
I try to connect to an internal (Informix) database server with the database explorer. The message on the message log is:

INFO [org.netbeans.modules.db.explorer.action.ConnectAction]
java.net.SocketException: Malformed reply from SOCKS server
        at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:129)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:460)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:208)
        at com.informix.asf.Connection.openSocket(Connection.java:1745)
Caused: com.informix.asf.IfxASFException: Attempt to connect to database server (prod1_tst) failed.
        at com.informix.util.IfxErrMsg.getLocIfxASFException(IfxErrMsg.java:750)
        at com.informix.asf.Connection.openSocket(Connection.java:1786)
        at com.informix.asf.Connection.<init>(Connection.java:391)
        at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1375)
Caused: java.sql.SQLException
        at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1391)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.informix.jdbc.IfxDriver.connect(IfxDriver.java:237)
        at org.netbeans.modules.db.explorer.DbDriverManager.getConnection(DbDriverManager.java:131)
        at org.netbeans.modules.db.explorer.DatabaseConnection.doConnect(DatabaseConnection.java:904)
        at org.netbeans.modules.db.explorer.DatabaseConnection.access$200(DatabaseConnection.java:103)
[catch] at org.netbeans.modules.db.explorer.DatabaseConnection$3.run(DatabaseConnection.java:970)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
Comment 7 matthias42 2014-12-12 20:29:52 UTC
(In reply to ogj from comment #6)
> I am also struggling with the "No proxy hosts" in Netbeans. 
> This is v8.0.2 on Linux (Fedora 20 and 21) againts an Informix database.
> 
> All internet access needs to go through the company proxy, but the database
> servers are local, and can not go via the proxy.
> 
> I have a manual proxy setup, and a list of hosts (the database servers) that
> should not be proxied (tried with wildcards, with and without FQDN, makes no
> difference).

I just had a look at the proxy code and ran debugging. This all checks out. I suspect wrong settings.

Please run netbeans with FINEST logging enabled:

<PATH_TO_NETBEAN>/bin/netbeans -J-Dorg.netbeans.core.network.proxy.NbProxySelector.level=FINEST

After that check the message log:

http://wiki.netbeans.org/FaqLogMessagesFile

You will find entries like:

http://wiki.netbeans.org/FaqLogMessagesFile

FINEST [org.netbeans.core.network.proxy.NbProxySelector]: NbProxySelector[Type: 2]. Host's IP 192.168.56.103 found in nonProxyHosts: localhost|127.0.0.1|athena|192.168.56.103
FINEST [org.netbeans.core.network.proxy.NbProxySelector]: NbProxySelector[Type: 2, Use HTTP for all protocols: false] returns [DIRECT] for URI socket://192.168.56.103:3306

In this case the IP I supplied for the mysql server was resolved to a direct connection. Maybe the log reveals your problem already (wrongly formated list of excluded hosts?).

Please note: The proxy settings have to be set in the Options dialog and the No Proxy Hosts entry is a comma seperated list.

If this still fails, put the complete log here (please note, that it takes a few seconds till the message log is written!)
Comment 8 ogj 2015-02-06 09:27:09 UTC
I do not get any output from the ProxySelector when I try to connect to the database.
But I do get an error, indicating that a connection through the proxy is tried:

FINEST [org.netbeans.core.network.proxy.NbProxySelector]: NbProxySelector[Type: 2, Use HTTP for all protocols: false] returns [HTTP @ /81.91.3.8:80, DIRECT] for URI http://www.netbeans.org/mtmo.xml?unique=NB
_EXTIDE_JAVA0e3da20aa-fe7c-419e-9c90-b993bef6b2ce
FINEST [org.netbeans.core.network.proxy.NbProxySelector]: NbProxySelector[Type: 2, Use HTTP for all protocols: false] returns [HTTP @ /81.91.3.8:80, DIRECT] for URI https://netbeans.org/mtmo.xml?unique=NB_EX
TIDE_JAVA0e3da20aa-fe7c-419e-9c90-b993bef6b2ce
INFO [org.netbeans.modules.db.explorer.action.ConnectAction]
java.net.SocketException: Malformed reply from SOCKS server
        at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:129)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:460)
        at java.net.Socket.connect(Socket.java:579)
        at java.net.Socket.connect(Socket.java:528)
        at java.net.Socket.<init>(Socket.java:425)
        at java.net.Socket.<init>(Socket.java:208)
        at com.informix.asf.Connection.openSocket(Connection.java:1745)
Caused: com.informix.asf.IfxASFException: Attempt to connect to database server (prod2_tst) failed.
        at com.informix.util.IfxErrMsg.getLocIfxASFException(IfxErrMsg.java:750)
        at com.informix.asf.Connection.openSocket(Connection.java:1786)
        at com.informix.asf.Connection.<init>(Connection.java:391)
        at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1375)
Caused: java.sql.SQLException
        at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1391)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at com.informix.jdbc.IfxDriver.connect(IfxDriver.java:237)
        at org.netbeans.modules.db.explorer.DbDriverManager.getConnection(DbDriverManager.java:131)
        at org.netbeans.modules.db.explorer.DatabaseConnection.doConnect(DatabaseConnection.java:904)
        at org.netbeans.modules.db.explorer.DatabaseConnection.access$200(DatabaseConnection.java:103)
[catch] at org.netbeans.modules.db.explorer.DatabaseConnection$3.run(DatabaseConnection.java:970)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)



The entries from the ProxySelector are probably caused by the newsfeed in the "What's new" Start Page. I have also tried both with and without ticking the "Use the same proxy settings for all protocols".

FINEST [org.netbeans.core.network.proxy.NbProxySelector]: NbProxySelector[Type: 2, Use HTTP for all protocols: false] returns [HTTP @ /81.91.3.8:80, DIRECT] for URI http://www.netbeans.org/mtmo.xml?unique=NB_EXTIDE_JAVA0e3da20aa-fe7c-419e-9c90-b993bef6b2ce
FINEST [org.netbeans.core.network.proxy.NbProxySelector]: NbProxySelector[Type: 2, Use HTTP for all protocols: false] returns [HTTP @ /81.91.3.8:80, DIRECT] for URI https://netbeans.org/mtmo.xml?unique=NB_EXTIDE_JAVA0e3da20aa-fe7c-419e-9c90-b993bef6b2ce
FINEST [org.netbeans.core.network.proxy.NbProxySelector]: NbProxySelector[Type: 2, Use HTTP for all protocols: false] returns [HTTP @ /81.91.3.8:80, DIRECT] for URI https://netbeans.org/mtmo.xml?unique=NB_EXTIDE_JAVA0e3da20aa-fe7c-419e-9c90-b993bef6b2ce


The "no-proxy hosts" are configured like this: tgdb1, tgdb2, tgcm1, tgcm2, tgtstcm1, tgtstcm2, tgtstdb1, tgtstdb2
Comment 9 ogj 2015-02-06 10:36:12 UTC
It works when I put in the IP-address in the "no proxy host" list!
The connect string is: 
jdbc:informix-sqli://tgtstcm1:50110/tgprod:INFORMIXSERVER=prod1_tst_oltp
Comment 10 matthias42 2015-02-06 19:27:47 UTC
@ogj:

Thank you for rechecking - after your update I tried to reproduce and this seems what happens:

The informix itself resolves the hostname to IP address and opens a socket with the IP. So the proxy selector only sees the IP and not the hostname, so this explains your finding.

In contrast to this the mysql code passes the hostname and in that case the proxy selector gets the hostname...