emscripten-core / emscripten-core/emscripten

tests/websocket/tcp_echo_client.cpp not works

Open
#11,627 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hi,
I tried to setup a wasm socket client and communicate with a TCP socket server.
it seems wasm socket could not communicate directly with TCP socket, I need to setup a socket proxy server to make it work.
I checked the guide here https://emscripten.org/docs/porting/networking.html#full-posix-sockets-over-websocket-proxy-server
and tried to run the sample in tests/websocket/tcp_echo_client.cpp, but it not works.
My steps is :
1. build tools/websocket_to_posix_proxy:
mkdir build
cd build
cmake ..
make
then I got the binary file websocket_to_posix_proxy in build folder
2. build tests/websocket/tcp_echo_client.cpp with command:
emcc tcp_echo_client.cpp -lwebsocket.js -s PROXY_POSIX_SOCKETS=1 -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 -o client.js
3. run the proxy with command: ./websocket_to_posix_proxy 8080
there's log:
websocket_to_posix_proxy server is now listening for WebSocket connections to ws://localhost:8080/

4. run client with command:
node --experimental-wasm-threads --experimental-wasm-bulk-memory client.js

the issue is: emscripten_websocket_get_ready_state(bridgeSocket, &readyState); the readyState always 0.
is anybody know the reason? is there any issue with my steps?
thank you very much!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.