Two major problem that prevent QT webassembly used in real project.
-
- Websocket doesn’t support SSL
I am senior in software development but new to QT. The QT feature of support multi-platform attract me, and I move my project into QT recently. The transplanting procedure in App for windows/linux is very good as expected. But the qt webassembly part is not so smoothly.
In order to support all the win/linux/web clients, I re-construct the data provider structure, use websocket(wss and ws) for all platforms. At beginning, my server use wss only, but when I found that Qt wasm cannot use ssl, I add ws support in the server. I use emrun to test and run the wasm project, everything look like ok, but when the project process nearly to the end. I try to deploy to the real product environment, I found I fall in a logical trap.
I configure a apache2.4 http server use http to run my qt wasm project. It can only access in 127.0.0.1 loopback interface. If I use real IP to open it, web browser prompt:
===
ReferenceError: SharedArrayBuffer is not defined
===
I check network and find its COEP problem, I force http server provide COEP header but it still didn’t work. At last I found in chrome debug information, that the browser igore COEP head if it’s not a https request. Then I configure apache httpserver with https. It work, but when the qt websocket connect to my server, web brower prompt:
VM70:7 Mixed Content: The page at 'https://10.168.2.80/gncscada.html' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://10.168.2.80:6113/'. This request has been blocked; this endpoint must be available over WSS.
I don’t know how to express my disappointment. I try microsoft edge and chrome, get the same result.
Today, all the browser require safety, so the qt websocket without ssl is useless in wasm.
For now, I can only try the websocket provide by emscripten to replace qt websocket.- Qt wasm cannot input chinese.
The websocket problem, I still can try other option. But this one, I have no idea how to solve it.
Below is a screen snapshot of my wasm project. I can input “admin”, but the following two chinese word, I cannot input it. For now I can only open a notepad, input chinese words, copy/paste to there.
I think not only chinese, other multibyte language will face to the same problem.
- Websocket doesn’t support SSL
-
which Qt version is used in your project?
you can file bugs here https://bugreports.qt.io/secure/Dashboard.jspa -
Hi,
- Use must use https for accessing threads which use javascript SharedArrayBuffer. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements
Qt Webassembly QNAM (QNetworkAccessManager) will access secure websockets (wss), just use https in the url. Also QWebSockets. If you need to use a custom certificate, you need to add it to the browser's certificates.
- This is fixed in 6.4 and 6.3 (or should be). See https://codereview.qt-project.org/c/qt/qtbase/+/416609
If this doesn't fix it completely, then please open a new bug report. https://bugreports.qt.io/secure/Dashboard.jspa
-
@lorn-potter
Thanks a lot. It's good news to hear that input bug will be solved soon.
About the QWebsocket, I haven't use QNetworkAccessManager because I don't use http get/post operation, I will try to research more about it. I am just using QWebSocket::sendTextMessage(sendmsg) to send request to server, and use QWebSocket::textMessageReceived(QString) signal to receive the reply from server. -
@lorn-potter I tried 6.4.2 and 6.5.0 Beat2 and still couldn't enter Chinese
-
@lorn-potter
Hi, several monthes passed after I open an issue QTBUG-107139, but haven't found progress. Which version will this problem be solved? -
@zhong-wenqing
The patch
https://codereview.qt-project.org/c/qt/qtbase/+/436295is still in review. I will bump it to the reviewers again.
-
@lorn-potter Thanks, the qt-bug system inform me today, this patch is merged into Qt6.6. I will try it.
-
-
-
@lorn.potter Hi, Is this issue very difficult to resolved? or not important? the new released versions all have this problem.