Socket io C++ Server does not respond to emit test

cocos2dx 3.17

I am having problems using socket io. I do not receive any kind of response from my android studio android emulator based client to my webstorm server test.

I try to emit a simple string to the server and have the console log it as seen below in the two examples:

Client Code:

Global::_sioClient = SocketIO::connect("http://192.168.0.1:9000", * this);

std::string examplestring = "tom";

Global::_sioClient->emit("emittest", examplestring);

Server Code:

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

port = 9000;
app.listen(port);
console.log('Listening on port: ' + port);

io.on("connection", (socket) => {
    console.log("New connexion..."); 
    console.log(socket); 

    socket.on("emittest", (examplestring) => {
        console.log(examplestring);
    });

});

When i run the sever in webstorm the listening on port 9000 message is displayed fine. but when i use my client to emit to the server nothing is ever received.

ok, tell us about your server setup.

Is there a firewall?

does it allow port 9000?

is something running on port 9000?

what does netstat say on your server?

There is i also have turned it off just for the duration of this test.

I opened the port 9000 in router settings and i do not see it listed in netstat

in Arris router settings:

	9000-9000	TCP	192.168.0.9	9000-9000

Netstat says:

TCP 192.168.0.9:139 0.0.0.0:0 LISTENING 4
TCP 192.168.0.9:5357 192.168.0.2:26372 TIME_WAIT 0
TCP 192.168.0.9:5357 192.168.0.2:26376 TIME_WAIT 0
TCP 192.168.0.9:5357 192.168.0.2:26412 TIME_WAIT 0
TCP 192.168.0.9:5357 192.168.0.2:26441 TIME_WAIT 0
TCP 192.168.0.9:63935 66.61.170.96:443 ESTABLISHED 4324

i do not have too much experience with netstat so please guide me through it :slight_smile: but it does not seem to be listed
i saw a lone one like this below is this it?

TCP [::]:9000 DESKTOP-SDBT2FF:0 LISTENING

another like it wayy at the top

TCP 0.0.0.0:9000 DESKTOP-SDBT2FF:0 LISTENING

Where is your server running? On your local machine? Some other machine? What is running on said machine to handle the request on port 9000?

on DESKTOP-SDBT2FF (the living room computer.)

i am using jetbrains Webstorm using the node.js installed socket io 2.0.4 i believe.

and is there a firewall running on the “living room computer”?

there was but just for the sake of this test i turned it off before attempting, and I am still having the same issue.

can you telnet to it?

yes it worked a blank screen was showed in cmd.

@slackmoehrle any other suggestions? telnet worked fine.

I’m not sure. It’s hard to tell you when I don’t know the “living room computer”. Let me see if I can try a test locally some how to verify what should be done. I’m not sure, but perhaps cpp-tests has an example too.

@slackmoehrle yes please run a test locally and if possible could you share that sample code with me and i will attempt to use it and based on what happens then it can help me figure out a solution. When you say “you don’t know the living room computer” are you saying you need computer specifications? if so i can provide some. I am sorry if i was vague or something it’s a rig i built so it does not really have a definite name listed anywhere.

What I mean is I don’t know how it is setup, what is running, etc, etc. It’s not in front of me to troubleshoot. I feel like this issue has something to do with setup and not necessarily code.

@slackmoehrle Windows 10, The network is normal really… I just have Spectrum internet and it is default router settings except for the port 9000 i opened. I haven’t changed anything ive only had it for 4-5 months. Is there any information i could provide to help?

Are you assigning onconnect listener?
Once you get onconnect response, after that try to emit.
Also you can refer to SocketIOTest.cpp in cpp-test, located at cocos2d-x\tests\cpp-tests\Classes\ExtensionsTest\NetworkTest