emscripten-core / emscripten-core/emscripten
tests/websocket/tcp_echo_client.cpp not works
- 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
Assessment
This issue has not been assessed yet.