Websocket can't connect from a browser to a server

206 views
Skip to first unread message

Denis Mihailovich

unread,
Mar 31, 2023, 11:57:25 AM3/31/23
to emscripten-discuss
As usual applications they connect well. But when I compiled the client with emscripten, I can't connect to the server.
In CXX_FLAGS I use "-s WEBSOCKET_URL=wss:// -s WEBSOCKET_SUBPROTOCOL='text'".
I built openssl in emscripten and link to it.
I generated a certificate and use it in both apps.
But in any case I get
```
sslv3 alert certificate unknown (SSL routines)
```
How should I use ssl in webasm? How should I use certificates? Did anybody do something like that?

Floh

unread,
May 10, 2023, 11:06:54 AM5/10/23
to emscripten-discuss
My guess is that websocket_client_sync_ssl.cpp is implementing a websocket client on top of 'raw' SSL and TCP (which is what's needed to talk to a websocket server from a native application, but is pointless in the browser).

Browsers already contain such a websocket client in form of the WebSocket Javascript API (https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API), Emscripten offers two API wrappers over websockets, one that's basically a 'POSIX socket emulation', and another that's a direct wrapper of the Javascript API:

Reply all
Reply to author
Forward
0 new messages