Websockets don't seem to work on chrome or edge, but do in firefox? #23101
Unanswered
retroprose
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I can't seem to get websockets working in chrome or edge, but they work no problem on firefox. It's odd because I compiled a bevy rust wasm project and it works fine on all three. The server url is the same for all of the programs, so it seems like there is nothing wrong on the server end. The server is running golang on render. It takes a minute to spin up, but then it streams data to the browser and 30 packets a second. This program just prints the size of the packets as it gets them. The first packet is one byte, then the rest are 268 bytes:
Paacket Size: 1
Paacket Size: 268
Paacket Size: 268
Paacket Size: 268
Paacket Size: 268
...
The example code is up on 'https://retroprose.net/files/debug-websocket/'
The app I'm trying to get working is at 'https://retroprose.net/files/test-cpp/'
The rust app can be seen here 'https://retroprose.net/files/wasm-rust-render/'
Here is the Makefile:
EMCC = emcc
SOURCES = src\main.cpp
EMFLAGS = -sSTACK_SIZE=5000000 -sALLOW_MEMORY_GROWTH -lwebsocket.js -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' --embed-file assets -std=c++17
build: $(SOURCES)
$(EMCC) $ (EMFLAGS) $(SOURCES) -o bin/index.html
And here is the main.cpp file:
`#include
#include <emscripten.h>
#include <emscripten/websocket.h>
EM_BOOL websocket_message(int eventType, const EmscriptenWebSocketMessageEvent *websocketEvent attribute((nonnull)), void *userData);
int main()
{
const char url[] = "wss://go-gin-web-server-32.onrender.com/session/0";
const char protocols[] = "binary";
}
inline EM_BOOL websocket_message(int eventType, const EmscriptenWebSocketMessageEvent *websocketEvent attribute((nonnull)), void *userData)
{
printf("Paacket Size: %d\n", websocketEvent->numBytes);
return true;
}`
Beta Was this translation helpful? Give feedback.
All reactions