[PR #4545] [client, signal] Refactor/reduce signaling #20641

Open
opened 2026-08-05 05:07:31 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4545
Author: @pappz
Created: 9/25/2025
Status: 🔄 Open

Base: mainHead: refactor/reducate-signaling


📝 Commits (10+)

  • 56c67fd Remove retry logic for P2P connection
  • 52d8bdf Merge branch 'main' into refactor/reducate-signaling
  • 0753766 Add signal error handling
  • 4d46adb Add wantDeliveryError option for signal proto
  • 71733df Add error code handling
  • 7ba8b92 Fix offer error sending channel
  • 9184a0c Update logs and doc
  • d9c585f allow ACK messages on signal
  • 2e20c97 Handle unimplemented method
  • 48e45b6 Resend msg

📊 Changes

20 files changed (+557 additions, -159 deletions)

View changed files

📝 client/cmd/testutil_test.go (+1 -1)
📝 client/internal/engine_test.go (+1 -1)
📝 client/internal/peer/conn.go (+53 -3)
client/internal/peer/guard.go (+10 -0)
📝 client/internal/peer/guard/guard.go (+40 -59)
client/internal/peer/guard/guard_retry.go (+139 -0)
📝 client/internal/peer/signaler.go (+35 -2)
📝 client/server/server_test.go (+1 -1)
📝 go.mod (+1 -1)
📝 go.sum (+2 -2)
📝 shared/signal/client/client.go (+1 -0)
📝 shared/signal/client/client_test.go (+1 -1)
📝 shared/signal/client/grpc.go (+36 -0)
📝 shared/signal/client/mock.go (+8 -0)
📝 shared/signal/proto/signalexchange.pb.go (+80 -69)
📝 shared/signal/proto/signalexchange.proto (+2 -0)
📝 shared/signal/proto/signalexchange_grpc.pb.go (+37 -0)
📝 signal/cmd/env.go (+14 -0)
📝 signal/cmd/run.go (+10 -3)
📝 signal/server/signal.go (+85 -16)

📄 Description

Describe your changes

When the client sends a signaling offer or answer, the Signal server may return an error if the message cannot be delivered. The client then checks the error type to decide how to proceed:

  • If the error suggests the remote peer is unavailable, the client waits for the peer instead of retrying immediately.
  • If the method is not implemented, then switch back to the original retry mechanism (backward compatibility case)
  • If the error indicates another error, the client retries by sending a new offer.

Whenever a peer reconnects to the signaling server and no active peer connection exists, it must send a new offer. This ensures that any signaling messages lost while the peer was offline are recovered and the connection can be re-established.

The NB_DISABLE_SEND_WITH_DELIVERY_CHECK: true|false option can be used to enforce that clients always use the server’s original methods.

For the review, keep in mind that these Signal server changes must support both old and new clients, and old clients must still connect properly with each other.

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/4545 **Author:** [@pappz](https://github.com/pappz) **Created:** 9/25/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `refactor/reducate-signaling` --- ### 📝 Commits (10+) - [`56c67fd`](https://github.com/netbirdio/netbird/commit/56c67fdf0819fdea9de00d40b6f9dd289f40c501) Remove retry logic for P2P connection - [`52d8bdf`](https://github.com/netbirdio/netbird/commit/52d8bdfc78a532727dc1efa64e55aafed0adb36b) Merge branch 'main' into refactor/reducate-signaling - [`0753766`](https://github.com/netbirdio/netbird/commit/07537663362fa031d9f22420754b1105f0a7eee0) Add signal error handling - [`4d46adb`](https://github.com/netbirdio/netbird/commit/4d46adbb6819e74371858eac6b219808a2239ff0) Add wantDeliveryError option for signal proto - [`71733df`](https://github.com/netbirdio/netbird/commit/71733dff3e02bc0ecccf0e021d9072921e249115) Add error code handling - [`7ba8b92`](https://github.com/netbirdio/netbird/commit/7ba8b926f0875e290d531b82b02504e1deef5255) Fix offer error sending channel - [`9184a0c`](https://github.com/netbirdio/netbird/commit/9184a0c6ac13f2c73cd31f712239e28a26b93ed2) Update logs and doc - [`d9c585f`](https://github.com/netbirdio/netbird/commit/d9c585f575a5b2545493f43447ce107094f8d821) allow ACK messages on signal - [`2e20c97`](https://github.com/netbirdio/netbird/commit/2e20c978b38ebe914b35a66d3cf4975faa7326f0) Handle unimplemented method - [`48e45b6`](https://github.com/netbirdio/netbird/commit/48e45b64bb6ac88226977383a908175ce71f22e5) Resend msg ### 📊 Changes **20 files changed** (+557 additions, -159 deletions) <details> <summary>View changed files</summary> 📝 `client/cmd/testutil_test.go` (+1 -1) 📝 `client/internal/engine_test.go` (+1 -1) 📝 `client/internal/peer/conn.go` (+53 -3) ➕ `client/internal/peer/guard.go` (+10 -0) 📝 `client/internal/peer/guard/guard.go` (+40 -59) ➕ `client/internal/peer/guard/guard_retry.go` (+139 -0) 📝 `client/internal/peer/signaler.go` (+35 -2) 📝 `client/server/server_test.go` (+1 -1) 📝 `go.mod` (+1 -1) 📝 `go.sum` (+2 -2) 📝 `shared/signal/client/client.go` (+1 -0) 📝 `shared/signal/client/client_test.go` (+1 -1) 📝 `shared/signal/client/grpc.go` (+36 -0) 📝 `shared/signal/client/mock.go` (+8 -0) 📝 `shared/signal/proto/signalexchange.pb.go` (+80 -69) 📝 `shared/signal/proto/signalexchange.proto` (+2 -0) 📝 `shared/signal/proto/signalexchange_grpc.pb.go` (+37 -0) 📝 `signal/cmd/env.go` (+14 -0) 📝 `signal/cmd/run.go` (+10 -3) 📝 `signal/server/signal.go` (+85 -16) </details> ### 📄 Description ## Describe your changes When the client sends a signaling offer or answer, the Signal server may return an error if the message cannot be delivered. The client then checks the error type to decide how to proceed: - If the error suggests the remote peer is unavailable, the client waits for the peer instead of retrying immediately. - If the method is not implemented, then switch back to the original retry mechanism (backward compatibility case) - If the error indicates another error, the client retries by sending a new offer. Whenever a peer reconnects to the signaling server and no active peer connection exists, it must send a new offer. This ensures that any signaling messages lost while the peer was offline are recovered and the connection can be re-established. The NB_DISABLE_SEND_WITH_DELIVERY_CHECK: true|false option can be used to enforce that clients always use the server’s original methods. For the review, keep in mind that these Signal server changes must support both old and new clients, and old clients must still connect properly with each other. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 05:07:31 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#20641