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. How to send json-file to the address?
Qt 6.11 is out! See what's new in the release blog

How to send json-file to the address?

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 4 Posters 4.7k Views
  • 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.
  • M Mikeeeeee

    I took the example code, and it says so:

    SslEchoClient::SslEchoClient(const QUrl &url, QObject *parent) :
        QObject(parent)
    {
        connect(&m_webSocket, &QWebSocket::connected, this, &SslEchoClient::onConnected);
        connect(&m_webSocket, QOverload<const QList<QSslError>&>::of(&QWebSocket::sslErrors),
                this, &SslEchoClient::onSslErrors);
        m_webSocket.open(QUrl(url));
    }
    

    There are signals and slots, I create an object of this class, but it does not connect. Why?

    J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #12

    @Mikeeeeee said in How to send json-file to the address?:

    QWebSocket::sslErrors

    why the overload ? as far as I can see sslErrors has no alternatives to QList<QSslErrors>

    https://doc.qt.io/qt-5/qwebsocket-members.html


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    1 Reply Last reply
    2
    • M Offline
      M Offline
      Mikeeeeee
      wrote on last edited by
      #13

      Tried to start an example "SslEchoClient", but it irzhe does not connect and does not display error messages.
      In my project I connected the status output to the button:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          myUrl = "wss://ws.binaryws.com/websockets/v3?app_id=xlY2chJRk0XoSL5";
          myWebSocket.open(QUrl(myUrl));
          qDebug()<<myWebSocket.isValid()<<myWebSocket.state();
      
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::on_testButton_clicked()
      {
          qDebug()<<myWebSocket.isValid()<<myWebSocket.state()<<myWebSocket.error();
      }
      

      Debug return:
      false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError
      false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError
      false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError
      false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError

      Why can't I even use the example "SslEchoClient" to connect to the websocket?

      jsulmJ 1 Reply Last reply
      0
      • M Mikeeeeee

        Tried to start an example "SslEchoClient", but it irzhe does not connect and does not display error messages.
        In my project I connected the status output to the button:

        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        
            myUrl = "wss://ws.binaryws.com/websockets/v3?app_id=xlY2chJRk0XoSL5";
            myWebSocket.open(QUrl(myUrl));
            qDebug()<<myWebSocket.isValid()<<myWebSocket.state();
        
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
        
        void MainWindow::on_testButton_clicked()
        {
            qDebug()<<myWebSocket.isValid()<<myWebSocket.state()<<myWebSocket.error();
        }
        

        Debug return:
        false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError
        false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError
        false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError
        false QAbstractSocket::UnconnectedState QAbstractSocket::UnknownSocketError

        Why can't I even use the example "SslEchoClient" to connect to the websocket?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #14

        @Mikeeeeee DO YOU HAVE ANY ERRORS WHEN TRYING TO CONNECT? After calling myWebSocket.open(QUrl(myUrl).
        Did you connect a slot to https://doc.qt.io/qt-5/qwebsocket.html#error-1 as I suggested?
        Is your onSslErrors called?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • M Offline
          M Offline
          Mikeeeeee
          wrote on last edited by
          #15

          I did, but debag doesn't say it was a error:

              myUrl = "wss://ws.binaryws.com/websockets/v3?app_id=xlY2chJRk0XoSL5";
              myWebSocket.open(QUrl(myUrl));
              //myWebSocket
              qDebug()<<myWebSocket.isValid()<<myWebSocket.state();
              connect(&myWebSocket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error),
                  [=](QAbstractSocket::SocketError error){ qDebug()<<"i have error";});
          

          Example "SslEchoClient" also no message, means no error, but the websocket is not connected.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mikeeeeee
            wrote on last edited by
            #16

            Do you have an example of "SslEchoClient" connecting to a websocket?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by
              #17

              Found this code. It is similar to worker.
              You do not know any besoket on which it is possible to check operability?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mikeeeeee
                wrote on last edited by
                #18

                If I use the program with GitHub, I get an error: "WebSocket::processHandshake: Unhandled http status code 301"
                Please tell me why and how to fix it?

                jsulmJ 1 Reply Last reply
                0
                • M Mikeeeeee

                  If I use the program with GitHub, I get an error: "WebSocket::processHandshake: Unhandled http status code 301"
                  Please tell me why and how to fix it?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #19

                  @Mikeeeeee If you use Google to search for "http 301" you will find https://en.wikipedia.org/wiki/HTTP_301 which tells you that 301 status code means "Moved Permanently is used for permanent URL redirection". What URL are you using?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • M Offline
                    M Offline
                    Mikeeeeee
                    wrote on last edited by Mikeeeeee
                    #20

                    Trying to connect to websocket "wss://ws.binaries.com/websockets/v3?app_id=1089".
                    Yesterday, he was connected here, and today is not connected.
                    Apparently he works on a certain time.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mikeeeeee
                      wrote on last edited by
                      #21

                      It looks like the bug of websocket. I connect to other web sites.

                      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