Answer the question
In order to leave comments, you need to log in
What is the problem of connecting to java server?
There is a vps with Linux Centos 6.5 I
run a simple java echo server on it. I tried to listen to different ports - 2525, 7070, 8080
Through iptables I opened tcp and udp connections to these ports, and icmp type 8
I start the server from su
I check the ping of the server - it's normal
Next I try to connect via flash from my site and via telnet from the command line
The situation is as follows - the server starts without errors, the axis writes that java is hanging on the right port, flash sends packets.
But there is no connection to the remote server through flash or telnet. Java does not write anything to the console either.
And everything works on localhost via telnet
Three days in Google did not produce results
. What could be the problem?
UPD: runserver
[[email protected] 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.class
import 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();
}
}
import 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 ){ ; }
}
}
}
Answer the question
In order to leave comments, you need to log in
I do not see the connection between CMS and data for the database.
I work with CMS Joomla! and the Helix3 template.
Everything suits me there: a lot of modules and little coding (for default projects, such as a blog, business cards, etc.).
What data is in your database? What will users do with them? Just text or will there be some calculations? What loads are expected?
How many fields per item? If we talk about Drupal, for example, then you may encounter the problem of the maximum number of joins in mysql, if you really have a lot of fields, and you will attach them all to the node.
In general, you need more information about your task in order to decide on the engine. I would advise you to use the same yii if possible.
what interface is the server listening on? maybe it waits for connections only locally?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question