Есть vps с Linux Centos 6.5
Запускаю на нем простенький эхо-сервер на java. Пробовал слушать разные порты - 2525, 7070, 8080
Через iptables открыл на эти порты tcp и udp соединения, и icmp type 8
Сервер запускаю от su
Проверяю ping сервера - нормально
Далее пробую подключится через flash со своего сайта и через telnet из командной строки
Ситуация такова - сервер запускается без ошибок, ось пишет что на нужном порте висит java, flash шлет пакеты.
Но ни через flash, ни через telnet подключения к удаленному серверу нет. Java в консоль тоже ничего не пишет.
А на localhost через telnet все работает
Три дня в гугле не дали результатов
В чем может быть проблема?
UPD: run server
[root@vm530723 SocketServer]# java -classpath . Server
SERVER :: started ServerSocket[addr=0.0.0.0/0.0.0.0,localport=8080]
SERVER :: wait for client
UPD: iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -i eth0 -p tcp -m tcp --dport 843 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 2525 -j ACCEPT
-A INPUT -i eth0 -p tcp -m tcp --dport 7070 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -p udp -m udp --dport 8080 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
UPD: server.classimport java.io.*;
import java.net.*;
public class Server {
public static void main(String[] args) throws IOException {
BufferedReader in = null;
PrintWriter out= null;
ServerSocket servers = null;
Socket fromclient = null;
// create server socket
try {
servers = new ServerSocket(8080);
System.out.println("SERVER :: started "+servers);
} catch (IOException e) {
System.out.println("SERVER :: couldn't listen to port 8080");
System.exit(-1);
}
try {
System.out.print("SERVER :: wait for client");
fromclient= servers.accept();
System.out.println("SERVER :: client connected");
} catch (IOException e) {
System.out.println("SERVER :: can't accept");
System.exit(-1);
}
in = new BufferedReader(new
InputStreamReader(fromclient.getInputStream()));
out = new PrintWriter(fromclient.getOutputStream(),true);
String input,output;
System.out.println("SERVER :: wait for messages");
while ((input = in.readLine()) != null) {
if (input.equalsIgnoreCase("exit")) break;
out.println("S ::: "+input);
System.out.println(input);
}
System.out.println("SERVER :: end of session");
out.close();
in.close();
fromclient.close();
servers.close();
}
}
UPD: multithreaded server.classimport java.io.*;
import java.net.*;
import java.lang.Thread;
public class EchoServer {
public static void main (String[] args) {
try {
ServerSocket server = new ServerSocket(8080, 0, InetAddress.getByName("server_ip"));
//ServerSocket server = new ServerSocket(8080); ТАКЖЕ НЕ РАБОТАЕТ
System.out.println("SERVER :: created "+server);
while (true) {
Socket client = server.accept();
System.out.println("SERVER :: got client");
EchoHandler handler = new EchoHandler(client);
handler.start();
}
}
catch (Exception e) {
System.err.println("SERVER :: Exception caught:" + e);
}
}
}
class EchoHandler extends Thread {
Socket client;
EchoHandler (Socket client) {
this.client = client;
}
public void run () {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter writer = new PrintWriter(client.getOutputStream(), true);
writer.println("SERVER :: [type 'bye' to disconnect]");
while (true) {
String line = reader.readLine();
if (line.trim().equals("bye")) {
writer.println("SERVER :: bye!");
break;
}
writer.println("SERVER :: [echo] " + line);
}
}
catch (Exception e) {
System.err.println("SERVER :: Exception caught: client disconnected.");
}
finally {
try { client.close(); }
catch (Exception e ){ ; }
}
}
}
UPD: netstat -an | grep "LIST"
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:47200 0.0.0.0:* LISTEN
tcp 0 0 :::111 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:631 :::* LISTEN
tcp 0 0 :::51934 :::* LISTEN
unix 2 [ ACC ] STREAM LISTENING 12215 @/var/run/hald/dbus-avqOESAjSU
unix 2 [ ACC ] STREAM LISTENING 12016 /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 8871 @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 12208 @/var/run/hald/dbus-HwJ9Avx459
unix 2 [ ACC ] STREAM LISTENING 12093 /var/run/cups/cups.sock
unix 2 [ ACC ] STREAM LISTENING 11653 /var/run/rpcbind.sock
unix 2 [ ACC ] STREAM LISTENING 12171 /var/run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 12783 public/cleanup
unix 2 [ ACC ] STREAM LISTENING 12790 private/tlsmgr
unix 2 [ ACC ] STREAM LISTENING 12794 private/rewrite
unix 2 [ ACC ] STREAM LISTENING 12798 private/bounce
unix 2 [ ACC ] STREAM LISTENING 12802 private/defer
unix 2 [ ACC ] STREAM LISTENING 12806 private/trace
unix 2 [ ACC ] STREAM LISTENING 12810 private/verify
unix 2 [ ACC ] STREAM LISTENING 12814 public/flush
unix 2 [ ACC ] STREAM LISTENING 12818 private/proxymap
unix 2 [ ACC ] STREAM LISTENING 12822 private/proxywrite
unix 2 [ ACC ] STREAM LISTENING 12826 private/smtp
unix 2 [ ACC ] STREAM LISTENING 12830 private/relay
unix 2 [ ACC ] STREAM LISTENING 12834 public/showq
unix 2 [ ACC ] STREAM LISTENING 12838 private/error
unix 2 [ ACC ] STREAM LISTENING 12842 private/retry
unix 2 [ ACC ] STREAM LISTENING 12846 private/discard
unix 2 [ ACC ] STREAM LISTENING 12850 private/local
unix 2 [ ACC ] STREAM LISTENING 12854 private/virtual
unix 2 [ ACC ] STREAM LISTENING 12858 private/lmtp
unix 2 [ ACC ] STREAM LISTENING 12862 private/anvil
unix 2 [ ACC ] STREAM LISTENING 12866 private/scache
unix 2 [ ACC ] STREAM LISTENING 12949 /var/run/abrt/abrt.socket