-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.19, 6.5.10, 6.8.5
-
None
Regarding Qt WebSocket, accessing via the wss domain works normally, but direct access to ip+port fails, though it works with the curl library. Do we have a solution for accessing the IP via wss?
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // SslEchoClient client(QUrl(QStringLiteral("wss://localhost:1234"))); // Q_UNUSED(client); QWebSocket webSocket; QUrl url("wss://cms.hrhgstock.com/auth/websocket/698a107f-fbed-42ae-aa25-2dcfad5af4af"); // Replace with your WebSocket server address QUrl url1("wss://47.111.28.134/auth/websocket/698a107f-fbed-42ae-aa25-2dcfad5af4af"); QNetworkRequest request(url1); request.setRawHeader("Host", url.host().toUtf8()); qDebug() << url.host(); qDebug() << url1.host(); // Obtain the default SSL configuration QSslConfiguration sslConfig = request.sslConfiguration(); //QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration(); // Set SNI Hostname request.setPeerVerifyName(url.host()); // Additional SSL options, such as the authentication mode, can be configured as needed. sslConfig.setPeerVerifyMode(QSslSocket::VerifyPeer); // Reset SSL configuration settings to request request.setSslConfiguration(sslConfig); // Signal Slot Connection QObject::connect(&webSocket, &QWebSocket::connected, []() { qDebug() << "test Connected!"; }); QObject::connect(&webSocket, &QWebSocket::disconnected, []() { qDebug() << "test Disconnected!"; }); QObject::connect(&webSocket, &QWebSocket::sslErrors, [](const QList<QSslError> &errors) { for (const QSslError &error : errors) { qDebug() << "SSL Error:" << error.errorString(); } }); // Open a WebSocket connection webSocket.open(request); return a.exec(); }