<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Unable to open WebSocket with a request parameter]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I'm developing a desktop and WASM app that opens a wss using a request instead of an url</p>
<pre><code>void open(const QNetworkRequest &amp;request)
</code></pre>
<p dir="auto">I need this approach because the server expects an Authentication Bearer token when request opening the socket.</p>
<pre><code>QNetworkRequest request(url);
QString header = "Bearer " + myToken;
request.setRawHeader("Authorization", header.toLocal8Bit());
this-&gt;wsocket-&gt;open(request);
</code></pre>
<p dir="auto">This works as expected on desktop platform, but doesn't work on WASM, where the server doesn't receive any request at all.</p>
<p dir="auto">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.</p>
<p dir="auto">Any suggestion -appart from sending the token using some other way-?<br />
Is it a Qt related issue or an emscripten limitation?</p>
<p dir="auto">Thks in advance</p>
]]></description><link>https://forum.qt.io/topic/150843/unable-to-open-websocket-with-a-request-parameter</link><generator>RSS for Node</generator><lastBuildDate>Tue, 19 May 2026 21:29:22 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/150843.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Oct 2023 06:58:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unable to open WebSocket with a request parameter on Wed, 24 Jul 2024 12:01:27 GMT]]></title><description><![CDATA[<p dir="auto">I had a problem with connection with the server on the free Glitch hosting from WASM. I solved it by setting <code>User-Agent</code>. I use Qt 6.6.3. Maybe it will help:</p>
<pre><code class="language-cpp">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);
</code></pre>
<p dir="auto">And I had another problem with connection from Android. I was solved it like this: <a href="https://forum.qt.io/topic/156035/small-examples-for-game-development-in-qt-opengl-box2d-bullet-physics-and-openal/32?_=1721822444763">Get data with Qt client from deployed Node.js server using WebSockets</a></p>
]]></description><link>https://forum.qt.io/post/802697</link><guid isPermaLink="true">https://forum.qt.io/post/802697</guid><dc:creator><![CDATA[8Observer8]]></dc:creator><pubDate>Wed, 24 Jul 2024 12:01:27 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to open WebSocket with a request parameter on Fri, 14 Jun 2024 10:06:53 GMT]]></title><description><![CDATA[<p dir="auto">Hi,<br />
Nope, not available from WASM<br />
Needed to conduct the authorization in some other way<br />
I'll check again on latest SDK 6.7.1 and related emscripten</p>
]]></description><link>https://forum.qt.io/post/802622</link><guid isPermaLink="true">https://forum.qt.io/post/802622</guid><dc:creator><![CDATA[imahgin]]></dc:creator><pubDate>Fri, 14 Jun 2024 10:06:53 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to open WebSocket with a request parameter on Wed, 15 May 2024 20:45:03 GMT]]></title><description><![CDATA[<p dir="auto">Hi.<br />
I faced the same issue...and the reasons why I need headers in request are the  same too...<br />
At least the issue presents in Qt 6.6.3.<br />
Do You have any solutions?</p>
]]></description><link>https://forum.qt.io/post/800123</link><guid isPermaLink="true">https://forum.qt.io/post/800123</guid><dc:creator><![CDATA[Delphi251189]]></dc:creator><pubDate>Wed, 15 May 2024 20:45:03 GMT</pubDate></item></channel></rss>