From f457238f835bf1548901926d5392be897df60293 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 3 Jul 2024 13:24:05 +0000 Subject: [PATCH 1/2] resume connection without initiating a new one Signed-off-by: Alexandra --- lib/nodes/webrtc/peer_connection.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/nodes/webrtc/peer_connection.cpp b/lib/nodes/webrtc/peer_connection.cpp index f8b50be73..ea24c77c8 100644 --- a/lib/nodes/webrtc/peer_connection.cpp +++ b/lib/nodes/webrtc/peer_connection.cpp @@ -230,7 +230,6 @@ void PeerConnection::onConnectionStateChange(rtc::PeerConnection::State state) { case rtc::PeerConnection::State::Closed: { logger->debug("Closed peer connection"); - resetConnectionAndStandby(lock); break; } } @@ -287,6 +286,7 @@ void PeerConnection::onSignalingMessage(SignalingMessage msg) { auto const &id = c.peerID; if (c.peers.size() < 2) { + logger->debug("Ignoring control message. Not enough peers."); resetConnectionAndStandby(lock); return; } @@ -300,6 +300,9 @@ void PeerConnection::onSignalingMessage(SignalingMessage msg) { snd = c.id; } } + logger->debug("Received control message: first={}, second={}, I am " + "{}", + fst, snd, id); standby = (id != fst && id != snd); @@ -309,6 +312,7 @@ void PeerConnection::onSignalingMessage(SignalingMessage msg) { return; } + logger->debug("firstID={}, secondID={}", firstID, secondID); if (fst == firstID && snd == secondID) { logger->debug("Ignoring control message. This connection is " "already being established."); @@ -321,8 +325,13 @@ void PeerConnection::onSignalingMessage(SignalingMessage msg) { firstID = fst; secondID = snd; + logger->debug("After resetConnection: first={}, second={}, I am {}", + fst, snd, first ? "first" : "second"); + setupPeerConnection(); + logger->debug("Setup peer connection successful"); + if (!first) { setupDataChannel(); conn->setLocalDescription(rtc::Description::Type::Offer); @@ -341,8 +350,10 @@ void PeerConnection::onSignalingMessage(SignalingMessage msg) { }, [&](rtc::Candidate c) { - if (standby || !conn) + if (standby || !conn){ + logger->debug("Ignoring candidate message. Not connected."); return; + } conn->addRemoteCandidate(c); }, From f8dd568b9d40d20163a5c10185d260ca3cca69f4 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Wed, 29 Oct 2025 10:51:39 +0000 Subject: [PATCH 2/2] Add webrtc integration test inlcuding peer restart Signed-off-by: Alexandra --- tests/integration/node-webrtc.sh | 134 +++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100755 tests/integration/node-webrtc.sh diff --git a/tests/integration/node-webrtc.sh b/tests/integration/node-webrtc.sh new file mode 100755 index 000000000..379acacbc --- /dev/null +++ b/tests/integration/node-webrtc.sh @@ -0,0 +1,134 @@ +#!/usr/bin/env bash +# +# Test for the webrtc node-type +# +# Author: Alexandra Bach +# SPDX-FileCopyrightText: 2014-2025 Institute for Automation of Complex Power Systems, RWTH Aachen University +# SPDX-License-Identifier: Apache-2.0 +set -x +set -e + +echo "The webrtc node restarts one peer, both peers, signaling server, and simulates connection loss." +# exit 99 + +DIR=$(mktemp -d) +pushd ${DIR} + +function finish { + popd + rm -rf ${DIR} +} +trap finish EXIT + +SERVER="https://villas.k8s.eonerc.rwth-aachen.de/ws/signaling" +SESSION="villas-integration-test" +FORMAT="json" + +cat > webrtc_siggen.json < webrtc_loopback.json <