There is a server from the example , listening on port 27018
Here is the server code:

var app = require("express")(); var http = require("http").Server(app); var io = require("socket.io")(http); n=27018; app.get("/", function(req, res){ res.sendFile(__dirname + '/index.html'); console.log('-------'); }); io.on('connection', function(socket){ console.log('a user connected'); socket.on('disconnect', function(){ console.log('user disconnected'); }); socket.on("chat message", function(msg){ io.emit('chat message', msg) }); }); http.listen(n, function(){ console.log("listening on *:"+n); }); 

Here is a customer

 package a41.a13.a4.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import android.widget.Toast; import java.net.URISyntaxException; import io.socket.client.IO; import io.socket.client.Socket; import io.socket.emitter.Emitter; public class LoginActivity extends AppCompatActivity { private Socket mSocket; TextView Exep; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); Exep = (TextView) findViewById(R.id.textView2);} public void Connect(View v){ try { mSocket = IO.socket("http://192.168.100.3:27018"); } catch (URISyntaxException e) { Exep.setText(e.toString()); } mSocket.connect(); }; 

The problem is that the client connects only to the local ip (the Connection triggered on the server), but it does not connect to the external ip.
But if you try to connect via a browser on a smartphone, then everything connects (to both external and local ip)
So the problem is in the client?

    1 answer 1

    The answer was found) the router dropped the connection when the connection came from the local network (even if you access an external ip) Roughly speaking, port forwarding rules did not work on the local network, and everything works fine from the Internet. Huawei HG8245H router model.


    and in the browser on the smartphone it worked because there was an analogue of the Opera Turbo function, connection through a proxy (speeding up the loading of pages, removal of ads, etc.), the UC Browser browser.