Unable to open WebSocket with a request parameter
-
wrote on 12 Oct 2023, 06:58 last edited by imahgin 10 Dec 2023, 07:07
Hi,
I'm developing a desktop and WASM app that opens a wss using a request instead of an urlvoid open(const QNetworkRequest &request)
I need this approach because the server expects an Authentication Bearer token when request opening the socket.
QNetworkRequest request(url); QString header = "Bearer " + myToken; request.setRawHeader("Authorization", header.toLocal8Bit()); this->wsocket->open(request);
This works as expected on desktop platform, but doesn't work on WASM, where the server doesn't receive any request at all.
I've tried it on several SDK version (5.15.2, 6.4.2, 6.5.3 and 6.6.0) with their respectives emscripten versions, but the same occurs.
Any suggestion -appart from sending the token using some other way-?
Is it a Qt related issue or an emscripten limitation?Thks in advance
-
wrote on 15 May 2024, 20:45 last edited by
Hi.
I faced the same issue...and the reasons why I need headers in request are the same too...
At least the issue presents in Qt 6.6.3.
Do You have any solutions? -
wrote on 14 Jun 2024, 10:05 last edited by imahgin
Hi,
Nope, not available from WASM
Needed to conduct the authorization in some other way
I'll check again on latest SDK 6.7.1 and related emscripten -
wrote on 15 Jun 2024, 10:43 last edited by 8Observer8
I had a problem with connection with the server on the free Glitch hosting from WASM. I solved it by setting
User-Agent
. I use Qt 6.6.3. Maybe it will help:QUrl url("wss://merciful-regal-soursop.glitch.me"); QNetworkRequest request; request.setUrl(url); request.setRawHeader(QByteArray("User-Agent"), QByteArray("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36")); m_webSocket.open(request);
And I had another problem with connection from Android. I was solved it like this: Get data with Qt client from deployed Node.js server using WebSockets
-
wrote on 24 Jul 2024, 06:20 last edited byThis post is deleted!