我正在开发一个Qt应用程序,它通过WebSocket与我的网络浏览器(目前是谷歌浏览器)进行通信.
一切都工作正常,直到我尝试使用安全的websockets ...
我设法解决了我在OpenSSL中遇到的问题,所以现在我应该有一个有效的Qt应用程序,但我没有.
我正在使用VS2013和Qt 5.3.我有以下代码来启动我的服务器:
MyClass::MyClass (quint16 port, QObject *parent) :
QWebSocketServer("Press And Listen Server", QWebSocketServer::SecureMode, parent) {
QSslConfiguration sslConfiguration;
QFile certFile (QStringLiteral ("localhost.crt"));
QFile keyFile (QStringLiteral ("localhost.key"));
certFile.open (QIODevice::ReadOnly);
keyFile.open (QIODevice::ReadOnly);
QSslCertificate certificate (&certFile, QSsl::Pem);
QSslKey sslKey (&keyFile, QSsl::Rsa, QSsl::Pem);
certFile.close ();
keyFile.close ();
sslConfiguration.setPeerVerifyMode (QSslSocket::VerifyNone);
sslConfiguration.setLocalCertificate (certificate);
sslConfiguration.setPrivateKey (sslKey);
sslConfiguration.setProtocol (QSsl::TlsV1SslV3);
this->setSslConfiguration (sslConfiguration);
if (!this->listen (QHostAddress::Any, port)) {
throw ServerNotStartedException () ;
}
qDebug () << "Server listenning on: " << port ;
connect (this, &QWebSocketServer::newConnection, this, …Run Code Online (Sandbox Code Playgroud) 假设我有一个可以随时接收事件的websocket,但是大多数是空闲的,在初始连接之后将消耗多少带宽以保持活动?
对于它的价值,服务器是NodeJS使用ws,客户端使用QtWebSockets.
谢谢!