Unable to open WebSocket with a request parameter
-
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
-
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? -
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