Problem to connect with JAVA
Posted: May 14th, 2010, 2:10 am
Hello 
I'm trying to connect my sabnzbd server with a little java software that i'm writing.
But it doesn't work and i don't understand why... so if anyone can help... (i'm not java noob but i dont find my mistake)
So i use :
The exception :
The url is okay (localhost, port 80, i desactivate the API key for test).
If i access sabnzbd via Chrome/FF/etc with the url "http://localhost/api?mode=queue&output=xml" it's working.
If i try to connect java to my apache webserver which is on the port 81, it's working.
and i can read the page on the BufferedReader.
So why it's not working with sabnzbd ? I'm sure it's a stupid mistake (it's always is) but i don't see it...
Thanks guys

I'm trying to connect my sabnzbd server with a little java software that i'm writing.
But it doesn't work and i don't understand why... so if anyone can help... (i'm not java noob but i dont find my mistake)
So i use :
Code: Select all
URL sabnzbd = new URL("http","localhost",-1,"api?mode=queue&output=xml");
BufferedReader in = new BufferedReader(new InputStreamReader(sabnzbd.openStream()));
Code: Select all
Exception in thread "main" java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at hello.main(hello.java:10)
If i access sabnzbd via Chrome/FF/etc with the url "http://localhost/api?mode=queue&output=xml" it's working.
If i try to connect java to my apache webserver which is on the port 81, it's working.
Code: Select all
URL sabnzbd = new URL("http","localhost",81,"");
BufferedReader in = new BufferedReader(new InputStreamReader(sabnzbd.openStream()));
So why it's not working with sabnzbd ? I'm sure it's a stupid mistake (it's always is) but i don't see it...
Thanks guys
