Problem to connect with JAVA

Got a program that plays well with SABnzbd? Share it here!
Post Reply
Sylver
Newbie
Newbie
Posts: 1
Joined: May 14th, 2010, 1:46 am

Problem to connect with JAVA

Post by Sylver »

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 :

Code: Select all

URL sabnzbd = new URL("http","localhost",-1,"api?mode=queue&output=xml");
BufferedReader in = new BufferedReader(new InputStreamReader(sabnzbd.openStream()));
The exception :

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)
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.

Code: Select all

URL sabnzbd = new URL("http","localhost",81,"");
BufferedReader in = new BufferedReader(new InputStreamReader(sabnzbd.openStream()));
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 :)
Last edited by Sylver on May 14th, 2010, 2:13 am, edited 1 time in total.
Post Reply