View Full Version : QSslSocket readyRead() signal problem

4th July 2012, 08:02
Hi all,
I'm writing a client application and ofc I need to read data from server.
When I get signal readyRead() i just read data.
The problem apears when serwer sends larger data.
Larger means 128bytes + header (6bytes).
In that case the signal "readyRead()" doesnt occure.
Additionaly after sending another data after this larger data, still signal doesnt show, when at start everything works great.
I also tryid with setting size of ReadBuffer manual but this doesnt help.
Did someone have problem like that or know how to make it work with larger data?
I tested it with 2 server: (1st in java, 2nd in qt), on both there is the same problem. So i think it must be client server.

19th February 2013, 12:05
Hi Dear
use this code:

class APHTTP : public QHttp

QString mHost;
QHttpRequestHeader mHeader;
QSslSocket socket;

public slots:
void findPageGet();
void socketReadyRead();
void socketEncrypted();
void sslErrors(QList<QSslError>);
void socketStateChanged(QAbstractSocket::SocketState);

mHost = "localhost";
connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)) ,
this, SLOT(socketStateChanged(QAbstractSocket::SocketSta te)));
connect(&socket, SIGNAL(encrypted()),
this, SLOT(socketEncrypted()));
connect(&socket, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(sslErrors(QList<QSslError>)));
connect(&socket, SIGNAL(readyRead()),
this, SLOT(socketReadyRead()));

socket.connectToHostEncrypted(mHost, 443, QIODevice::ReadWrite);
if (!socket.waitForEncrypted())
qDebug() << socket.errorString();
return ;
connect(this, SIGNAL(done(bool)), this, SLOT(findPageGet()));
// you should set header!!!!!!!!!
this->setHost(mHost, QHttp::ConnectionModeHttp);

void APHTTP::findPageGet()
QByteArray bytData;
QMutex mutex;
QString body;

bytData = this->readAll();
body = QString::QString(bytData);

void APHTTP::socketReadyRead()
QString str;

str = QString::fromUtf8(socket.readAll());

void APHTTP::sslErrors( QList<QSslError> error)

void APHTTP::socketEncrypted()

void APHTTP::socketStateChanged( QAbstractSocket::SocketState state )

19th February 2013, 17:39
I would suggest to use QNetworkAccessManager instead of QHttp. The latter is deprecated and the former can handle SSL itself.