Skip to content

Client: C++ client connections lost upon migration from 2.3.0 to 3.0.1 #3698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
AdrianDC opened this issue Nov 17, 2020 · 1 comment
Closed
1 of 2 tasks

Comments

@AdrianDC
Copy link

You want to:

  • report a bug
  • request a feature

Current behaviour

Upon migration from Socket.IO 2.3.0 to 3.0.1 and related adaptations,
the socket.io-client-cpp connections are no longer detected by the server.

Only a new socket("/namespace/") call in C++ triggers an event.

Steps to reproduce (if the current behaviour is a bug)

File test.js : test.js

File test.cpp : test.cpp

Compile socket.io-client-cpp and test :

git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git
docker run -i --entrypoint bash --rm -v "$PWD:$PWD" -w "$PWD" node:12-stretch <<EOF
cd ./socket.io-client-cpp/
apt update
apt install -y libboost-all-dev build-essential cmake libssl1.0-dev make
cmake .
make install
cd ../
g++ -std=c++11 -Isocket.io-client-cpp/build/include -lboost_system -lpthread -o test test.cpp ./socket.io-client-cpp/build/lib/Release/libsioclient.a
EOF

Run with [email protected] and results :

docker run -i --entrypoint bash --rm -v "$PWD:$PWD" -w "$PWD" node:12-stretch <<EOF
apt update
apt install libboost-system1.62.0
npm install express http [email protected]
echo ''
{
  node ./test.js &
  server=${!}
  sleep 2
  timeout 3 ./test
  echo ''
  timeout 3 ./test true
  echo ''
  timeout 3 ./test true true
  kill -9 "${server}"
}
EOF

Run with [email protected] :

docker run -i --entrypoint bash --rm -v "$PWD:$PWD" -w "$PWD" node:12-stretch <<EOF
apt update
apt install libboost-system1.62.0
npm install express http [email protected]
echo ''
{
  node ./test.js &
  server=${!}
  sleep 2
  timeout 3 ./test
  echo ''
  timeout 3 ./test true
  echo ''
  timeout 3 ./test true true
  kill -9 "${server}"
}
EOF

Results with [email protected] :

[SERVER] Using [email protected] syntax 
[SERVER] Server listening on http://127.0.0.1:3000
[CLIENT] Connecting to http://127.0.0.1:3000...
[CLIENT] Connected                                        
[SERVER] Expected "use()" {"EIO":"4","transport":"websocket","t":"1605634708","query1":"data1","query2":"data2"}
[SERVER] Expected "of("").use()" {"EIO":"4","transport":"websocket","t":"1605634708","query1":"data1","query2":"data2"} 
[SERVER] Expected "of("/").use()" {"EIO":"4","transport":"websocket","t":"1605634708","query1":"data1","query2":"data2"}
[SERVER] Expected "connect" {"EIO":"4","transport":"websocket","t":"1605634708","query1":"data1","query2":"data2"}
[SERVER] Expected "connection" {"EIO":"4","transport":"websocket","t":"1605634708","query1":"data1","query2":"data2"}
[CLIENT] Interrupting...
[CLIENT] State: Connected
[CLIENT] Disconnected
[SERVER] Expected "disconnect" (use())
[SERVER] Expected "disconnect" ("")
[SERVER] Expected "disconnect" ("/")
[SERVER] Expected "disconnect" ("connect")
[SERVER] Expected "disconnect" ("connection")

[CLIENT] Connecting to http://127.0.0.1:3000...
[CLIENT] Connected
[SERVER] Expected "use()" {"EIO":"4","transport":"websocket","t":"1605634714","query1":"data1","query2":"data2"}
[SERVER] Expected "of("").use()" {"EIO":"4","transport":"websocket","t":"1605634714","query1":"data1","query2":"data2"}
[SERVER] Expected "of("/").use()" {"EIO":"4","transport":"websocket","t":"1605634714","query1":"data1","query2":"data2"}
[SERVER] Expected "connect" {"EIO":"4","transport":"websocket","t":"1605634714","query1":"data1","query2":"data2"}
[SERVER] Expected "connection" {"EIO":"4","transport":"websocket","t":"1605634714","query1":"data1","query2":"data2"}
[SERVER] Expected "of("/user/").use()" {"EIO":"4","transport":"websocket","t":"1605634714","query1":"data1","query2":"data2"}
[CLIENT] Interrupting...
[CLIENT] State: Connected
[CLIENT] Disconnected
[SERVER] Expected "disconnect" (use())
[SERVER] Expected "disconnect" ("")
[SERVER] Expected "disconnect" ("/")
[SERVER] Expected "disconnect" ("connect")
[SERVER] Expected "disconnect" ("connection")
[SERVER] Expected "disconnect" ("/user/")

[CLIENT] Connecting to http://127.0.0.1:3000...
[CLIENT] Connected
[SERVER] Expected "use()" {"EIO":"4","transport":"websocket","t":"1605634720","query1":"data1","query2":"data2"}
[SERVER] Expected "of("").use()" {"EIO":"4","transport":"websocket","t":"1605634720","query1":"data1","query2":"data2"}
[SERVER] Expected "of("/").use()" {"EIO":"4","transport":"websocket","t":"1605634720","query1":"data1","query2":"data2"}
[SERVER] Expected "connect" {"EIO":"4","transport":"websocket","t":"1605634720","query1":"data1","query2":"data2"}
[SERVER] Expected "connection" {"EIO":"4","transport":"websocket","t":"1605634720","query1":"data1","query2":"data2"}
[CLIENT] Interrupting...
[CLIENT] State: Connected
[CLIENT] Disconnected
[SERVER] Expected "disconnect" (use())
[SERVER] Expected "disconnect" ("")
[SERVER] Expected "disconnect" ("/")
[SERVER] Expected "disconnect" ("connect")
[SERVER] Expected "disconnect" ("connection")

Results with [email protected] :

[SERVER] Using [email protected] syntax
[SERVER] Server listening on http://127.0.0.1:3000
[CLIENT] Connecting to http://127.0.0.1:3000...
[CLIENT] Connected
[CLIENT] Interrupting...
[CLIENT] State: Connected
[CLIENT] Disconnected

[CLIENT] Connecting to http://127.0.0.1:3000...
[CLIENT] Connected
[SERVER] Expected "of("/user/").use()" {"EIO":"4","transport":"websocket","t":"1605634663","query1":"data1","query2":"data2"}
[CLIENT] Interrupting...
[CLIENT] State: Connected
[CLIENT] Disconnected
[SERVER] Expected "disconnect" ("/user/")

[CLIENT] Connecting to http://127.0.0.1:3000...
[CLIENT] Connected
[CLIENT] Interrupting...
[CLIENT] State: Connected
[CLIENT] Disconnected

Expected behaviour

While the default namespace is no longer detected on [email protected],
I need a way to detect the connection regardless of the namespace to register the existing C++ clients.

Changes introduced in the 3289f7e commit now prevents us
from detecting an "incoming" Client connection, although it does not open a Socket on a namespace,
this is valuable information for specific use cases.

I restored compatibility with the 2.3.0 server by applying this patch after installations :

sed -i "s#\(        \)\(new client_1.Client.*\)#\1const client = \2\n        client.connect(\"/\");#g" ./node_modules/socket.io/dist/index.js

Per the https://socket.io/docs/v3/namespaces/index.html#Default-namespace documentation,
the default namespace "/" should be at least accessible, even explicitly.

Setup

  • OS: Debian Stretch and CentOS 7
  • Node.js : 12.19.1
  • socket.io version: 3.0.1 and 2.3.0

Other information (e.g. stacktraces, related issues, suggestions how to fix)

For CentOS 7 targets, compatibility for socket.io-client-cpp : socketio/socket.io-client-cpp#271

@darrachequesne
Copy link
Member

The C++ client now supports Socket.IO v3: https://github.com/socketio/socket.io-client-cpp/releases/tag/3.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants