diff --git a/debian/nymea-remoteproxy.install.in b/debian/nymea-remoteproxy.install.in index 888197e..3522567 100644 --- a/debian/nymea-remoteproxy.install.in +++ b/debian/nymea-remoteproxy.install.in @@ -1,2 +1,3 @@ usr/bin/nymea-remoteproxy nymea-remoteproxy.conf etc/nymea/ +nymea-remoteproxy-logging.conf etc/nymea/ diff --git a/debian/nymea-remoteproxy.service b/debian/nymea-remoteproxy.service index af023ee..ccb8118 100644 --- a/debian/nymea-remoteproxy.service +++ b/debian/nymea-remoteproxy.service @@ -6,6 +6,7 @@ Wants=network-online.target [Service] Type=simple +Environment=QT_LOGGING_CONF=/etc/nymea/nymea-remoteproxy-logging.conf ExecStart=/usr/bin/nymea-remoteproxy -c /etc/nymea/nymea-remoteproxy.conf StandardOutput=journal StandardError=journal diff --git a/libnymea-remoteproxy/proxyserver.cpp b/libnymea-remoteproxy/proxyserver.cpp index 089f9cc..8c451d5 100644 --- a/libnymea-remoteproxy/proxyserver.cpp +++ b/libnymea-remoteproxy/proxyserver.cpp @@ -254,6 +254,8 @@ void ProxyServer::onClientDisconnected(const QUuid &clientId) // Delete the proxy client proxyClient->deleteLater(); + } else { + qCWarning(dcProxyServer()) << "Unknown client disconnected from proxy server." << clientId.toString(); } } diff --git a/libnymea-remoteproxy/websocketserver.cpp b/libnymea-remoteproxy/websocketserver.cpp index 7eb214a..7e49836 100644 --- a/libnymea-remoteproxy/websocketserver.cpp +++ b/libnymea-remoteproxy/websocketserver.cpp @@ -93,6 +93,10 @@ void WebSocketServer::onClientConnected() { // Got a new client connected QWebSocket *client = m_server->nextPendingConnection(); + if (!client) { + qCWarning(dcWebSocketServer()) << "Next pending connection dissapeared. Doing nothing."; + return; + } // Check websocket version if (client->version() != QWebSocketProtocol::Version13) { @@ -149,7 +153,10 @@ void WebSocketServer::onBinaryMessageReceived(const QByteArray &data) void WebSocketServer::onClientError(QAbstractSocket::SocketError error) { QWebSocket *client = static_cast(sender()); - qCWarning(dcWebSocketServer()) << "Client error occurred:" << error << client->errorString(); + qCWarning(dcWebSocketServer()) << "Client error occurred:" << client << client->peerAddress().toString() << error << client->errorString() << "Closing the socket."; + + // Note: on any error which can occure, make sure the socket will be closed in any case + client->close(); } void WebSocketServer::onAcceptError(QAbstractSocket::SocketError error) diff --git a/nymea-remoteproxy-logging.conf b/nymea-remoteproxy-logging.conf new file mode 100644 index 0000000..71477ef --- /dev/null +++ b/nymea-remoteproxy-logging.conf @@ -0,0 +1,15 @@ +[Rules] +*.debug=false +Application.debug=true +Engine.debug=true +JsonRpc.debug=true +JsonRpcTraffic.debug=false +WebSocketServer.debug=true +WebSocketServerTraffic.debug=false +Authentication.debug=true +AuthenticationProcess.debug=false +ProxyServer.debug=true +ProxyServerTraffic.debug=false +MonitorServer.debug=true +AwsCredentialsProvider.debug=false +AwsCredentialsProviderTraffic.debug=false