Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT MQTT TLS Failed
Qt 6.11 is out! See what's new in the release blog

QT MQTT TLS Failed

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 822 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arilink
    wrote on last edited by arilink
    #1

    Development environment
    1.windows10 x64
    2.qt and mqtt version 5.15.2
    3.compiler: mingw 8.1
    Question:
    I tried to add the TLS function on the basis of mqtt client to facilitate secure transmission, but after turning on TLS, I cannot connect to the server. The error message is 256 QMqttClient::TransportInvalid

    Code:
    m_client = new QMqttClient(this);
    const QString hostname{"test.mosquitto.org"};
    const quint16 port = 8883;
    if(QSslSocket::supportsSsl())
    {
    qDebug()<<"SSL SUPORTED";
    };
    QSslCertificate cert = QSslCertificate(pem,QSsl::Pem);
    QSslConfiguration conf;
    conf.setCaCertificates({cert});
    conf.setProtocol(QSsl::TlsV1_2);
    m_client->setHostname(hostname);
    m_client->setPort(port);
    QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
    m_client->connectToHostEncrypted(conf);

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gguns
      wrote on last edited by
      #2

      Hello, did you get this to work? I'm having the same error (QMqttClient::TransportInvalid)

      JKSHJ 1 Reply Last reply
      0
      • G gguns

        Hello, did you get this to work? I'm having the same error (QMqttClient::TransportInvalid)

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        Hi @gguns, and welcome!

        For a quick sanity check: Are you able to use a QSslSocket to connect to your MQTT broker? (If this doesn't work, then QMqttClient won't be able to connect either)

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved