2017-09-21 3 views
0

Basisinformationen:
Ich versuche, eine Java-Anwendung zu erhalten, um über SOCKS Proxy eine Verbindung zu einem Ziel herzustellen. Ich fand this auf herauszufinden, wie man Proxy-Einstellungen zu konfigurieren, was wichtig ist, wie ich den Quellcode nicht ändern kann, um Proxy-Nutzung zu konfigurieren. Die Anwendung hat jedoch keine Verbindung über den Proxy hergestellt.JVM und SocksProxy Einstellungen funktionieren nicht auf Ubuntu 16.04

Einzelheiten
Ich verwende eine kleine benutzerdefinierte Klasse dies für die Prüfung, die genau eine Hauptmethode hat und tut dies:

public static void main(String... strings) throws URISyntaxException, IOException { 
    URL url = new URI("http", null, "localhost", 9998, null, null, null).toURL(); 
    System.out.println("opening connection to " + url.toString()); 
    URLConnection c = url.openConnection(); 
    System.out.println("connecting"); 
    c.connect(); 
    System.out.println(c.getContentLength()); 
    System.out.println(c.getContentType()); 
} 

Dann fange ich an, dass die Klasse mit java <properties> <classname>. Eigenschaften Ich habe bisher versucht (Einzel und kombiniert):

  1. socksPropertyHost=localhost
  2. socksPropertyPort=9999
  3. http.proxySet=true
  4. http.proxyHost=localhost
  5. http.proxyPort=9999
  6. https.proxySet=true
  7. https.proxyHost=localhost
  8. https.proxyPort=9999
  9. proxySet=true
  10. proxyHost=localhost
  11. proxyPort=9999
  12. java.net.useSystemProxies=true

Ebenso Ich habe diese auf der Kommandozeile, dann zu meiner Umgebung, stellen Sie die Werte in jre/lib/net.properties und sie schmollen in eine durch Kommas getrennte Liste, die dann als -D$JAVA_OPTS in einem Bash-Skript übergeben wurde.

Alle Verbindungen mit

Exception in thread "main" java.net.ConnectException: Connection refused (Connection refused) 
    at java.net.PlainSocketImpl.socketConnect(Native Method) 
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) 
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) 
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) 
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
    at java.net.Socket.connect(Socket.java:589) 
    at java.net.Socket.connect(Socket.java:538) 
    at sun.net.NetworkClient.doConnect(NetworkClient.java:180) 
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) 
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) 
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) 
    at sun.net.www.http.HttpClient.New(HttpClient.java:339) 
    at sun.net.www.http.HttpClient.New(HttpClient.java:357) 
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202) 
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138) 
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032) 
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966) 
    at sandbox.Sandbox.main(Example.java:16) 

Grundsätzlich verweigert wurde, die Frage (n) hier ist/sind/diese:

Bin ich etwas falsch hier? Ist das ein Fehler? Ist es nur mein System? Jede Antwort würde sehr geschätzt werden.

+1

-D nimmt keine kommagetrennte Liste. Sie benötigen für jede Eigenschaft, die Sie festlegen möchten, ein -D. –

+0

Okay, um zu verdeutlichen: Ich habe jede einzelne Variable auf der Kommandozeile hinzugefügt (über '-Done, -Dtwo, -DThree'), ich habe sie der Umgebung hinzugefügt, indem ich sie zu' application.properties' gesetzt habe Jeder Wert in 'net.properties' und, in Verzweiflung, versuchte ein Bash-Skript, das sie in einer einzigen Zeichenfolge kombiniert. –

+0

Ihr Szenario kann nicht einfach von Ihrer Frage reproduziert werden, und ich glaube nicht, dass _all_ die Verbindungen mit genau der gleichen Stack-Ablaufverfolgung abgelehnt wurden. –

Antwort