This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes connection refused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "connection refused" Watch "connection refused" New topic
Author

connection refused

hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
i try to connect to device
by this code
and i got java.net.ConnectException: Connection refused why


import java.io.IOException;

import java.net.*;
public class Connector {
Socket s;
Connector() throws Exception{
int port=5010;
String ip="192.168.1.81";
s=new Socket(ip,port);

}

public static void main(String arg[]){
Connector connector;
try{
connector=new Connector();
}catch(IOException ee){

ee.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


}
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Is there a service running on port 5010 of the destination machine? Is there a firewall or proxy between the machine you are running the program on and the destination?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
this device is OC200


OC200 proximity card time attendance and access control
you can find it here

http://anviz.en.alibaba.com/product/0/201783800/Others/OC200_proximity_card_time_attendance_and_access_control.html
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Do you have documentation? What does it say about contacting the device?
Do you have a vendor contact?
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
i have documentation printed code for programe write vb6


it says the port is 5010 and ip 192.168.1.81

and admin password is 8888

and i can change this password and this ip
i have check this ip and password from device it self
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Wouldn't the IP depend on your network? Is there a way you can check/configure the IP and port on the device?
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
i can change ip ,but port no
buy the way i can ping on this ip address
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Does some other device/computer on your network have the same IP?
Turn the device off and try to ping it.
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
NO when i turn it off i could not ping it

does it need user name and password???
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

That's where your documentation comes in. I've never used the device. I can only help you with the general network stuff.
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
documentation say nothing about that i am just trying to find the reason
and and meaning of connection refused ?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

"connection refused" usually means there's no process bound to that port to receive a connection.
Since we've established that the IP's correct and you have a path to the device, it really boils down to the port.
Check the documentation and contact the vendor.
You could try running the VB program and see if that works with the same IP and port.
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
do you now how can i scan port on this device while i am using linux
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Try making a connection to each port in turn (there's 65000 of them). If you don't get an exception, something is listening.
Of course, this practice is frowned upon as it is considered an attack by network administrators. You may want to clear it with them before you go banging away.
hassan ali
Ranch Hand

Joined: Apr 23, 2006
Posts: 127
after discussion

and trying i got that this work as client to specific server ip address

so my machine must have this ip and to be server for this client

that mean use socket server to listen on port 5010 not client socket that

call this device.. i hope it is clear for any body, your program with this

device must work as server for it.

thanks JavaRanche
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: connection refused
 
Similar Threads
port scanning
java.net.Connect Exception: Connection refused java.lang.Null Pointer Exception
Want to connect to computer over internet. Getting exception- Connection refused:connect
To validate telnet connectivity in java code
What's wrong here!