How to send json-file to the address?
-
@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> -
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::UnknownSocketErrorWhy can't I even use the example "SslEchoClient" to connect to the websocket?
-
@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? -
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.
-
@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?