File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection refused

 
hassan ali
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
hassan ali
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have documentation? What does it say about contacting the device?
Do you have a vendor contact?
 
hassan ali
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can change ip ,but port no
buy the way i can ping on this ip address
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NO when i turn it off i could not ping it

does it need user name and password???
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
documentation say nothing about that i am just trying to find the reason
and and meaning of connection refused ?
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you now how can i scan port on this device while i am using linux
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic