So I have the following TCP Server which will be online on a cloud in Node JS, and im trying to make an Android Client connect Via SOCKETS. Which work in the following way.
-Android Client must connect to listening port of server in internet (NOT LOCALHOST)
-Android Client must send public ip to server so the server will know who to answer to
-NodeJS TCP Server must write back to Android Client
-Android Client will do stuff from answer recieved..
So this is my Node TCP Server
var net = require('net');
var server = net.createServer();
server.on("connection", function (socket) {
var remoteAddress = socket.remoteAddress + ": " + socket.remotePort;
console.log("Se conecto una camara cliente: %s", remoteAddress);
socket.on("data", function (d) {
var ladrido = true;
if (ladrido) {
console.log("Data from %s: %s", remoteAddress, d);
socket.write("Hello " + d);
}
});
socket.once("close", function (d) {
console.log("Se cerro el socket de connexion: %s", remoteAddress);
});
socket.on("error", function (err) {
console.log("Connexion %s error: %s", remoteAddress, err.message);
});
});
server.listen(9000, function () {
//console.log("server escuchando en %j", server.address());
console.log("Server escuchando en el puerto 9000");
});
I have tested the server via PacketSender (Software made to test connections) And it works properly on localhost
My problem is Android Client never reaches the server.. Can anyone help me with this?
via Roger Ahumada
No comments:
Post a Comment