Closed ligalath closed 6 months ago
WEBSOCKET_URL pertains to Emscripten's automatic POSIX sockets -> WebSockets translation. The idea of this mode is to enable emulation for a C program that used POSIX sockets API to compile with Emscripten, and the POSIX sockets calls would be transformed into a WebSockets connection. WEBSOCKET_URL controls the URL to connect to - I think one connect() target is supported.
(or it might be that the URL specifies the address of an intermediary WebSockify proxy and not the destination - I forget, never really used this emulation path)
This is the section Emulated POSIX TCP Sockets over WebSockets in the docs.
If you just want to directly do WebSockets, you can use the Emscripten WebSockets API.
I viewd the WebSocketsAPI and tried it. But it uses the http to establish connect while I would like to use https that is wss.
still cannot find anyway to use https to establish websocket connect. Move on to send https directly with C in WASM. But is there any methods to use posix socket itself, or any posix socket will be transfered to WebSocket instead? I've read this part. thx Emulated POSIX TCP Sockets over WebSockets
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.
Why is this closed? Encryption of all things like HTTP and Websockets is essential for everybody. This has got nothing to do with emulating HTTP over websockets.
still cannot find anyway to use https to establish websocket connect. Move on to send https directly with C in WASM. But is there any methods to use posix socket itself, or any posix socket will be transfered to WebSocket instead? I've read this part. thx Emulated POSIX TCP Sockets over WebSockets
There is no way to open an actual TCP/UDP socket on the web today so any BSD socket API usage much be converted to something like WebSocket that is supported in the web.
Why is this closed? Encryption of all things like HTTP and Websockets is essential for everybody. This has got nothing to do with emulating HTTP over websockets.
This was closed due to inactivity. I've now re-opened it as per the process described in https://github.com/emscripten-core/emscripten/issues/11288#issuecomment-853164588.
We do have a C WebSocket API already: https://emscripten.org/docs/porting/networking.html#emscripten-websockets-api https://github.com/emscripten-core/emscripten/blob/main/system/include/emscripten/websocket.h
Its not clear to be that this doesn't support HTTPS already. Do you have reason to believe this API is HTTPS support? Perhaps it just be a case of specifying an HTTPS URL here: https://github.com/emscripten-core/emscripten/blob/165ad5e72be5ff0f295dca812246b583186048f4/system/include/emscripten/websocket.h#L83-L85
@ligalath have you tried using the API in websocket.h?
@ligalath the documentation for WEBSOCKET_URL is here:
It looks like you can set -sWEBSOCKET_URL=wss://
if you want the emulation of POSIX sockets to go over wss://
To my understanding the WebSockets API in websocket.h should not have any hardcoded tie-in to ws://
operation, but should be possible to pass wss://
URL if you want to connect to a secure WebSockets endpoint.
Chrome and some other browsers do not allow wss connections over http u have to be running an https server to connect over wss and u cannot connect to a ws socket in https.
Chrome and some other browsers do not allow wss connections over http u have to be running an https server to connect over wss and u cannot connect to a ws socket in https.
My understanding is that you can use wss://
today with emscripten. Are you not able to for some reason?
No you cannot connect to a secure websocket from a unsecure webpage (http). Even from emscripten. You have to be on a https website to connect to a secure websocket.
No you cannot connect to a secure websocket from a unsecure webpage (http). Even from emscripten. You have to be on a https website to connect to a secure websocket.
I see, but that isn't a bug in emscripten is it? That sounds like just a statement about web standards which emscripten has not control over, right?
Yes emscripten isnt responsible, emscripten has no bug in the websoickets they work as they are intended to. emscripten just uses the webbrowsers websocket libary. so it is dependent on the web browser it self not emwscripten. I know for sure u can connect to unsecure websockets over unsecure http webpages in firefox but not chrome. chrome wont even let you conneect to websockets if they arnt secure and on a secure page.
Is there any support for wss(WebSocket + Https) in C? I've viewed the documents and relevant code, and didn't found it. If there is, how should I use it? What is compile option WEBSOCKET_URL for?