[PR #771] [CLOSED] Add grpc keep alive for management service #12973

Closed
opened 2026-08-05 02:07:08 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/771
Author: @pappz
Created: 3/28/2023
Status: Closed

Base: mainHead: feature/keep_alive


📝 Commits (8)

  • e376541 Add grpc keep alive for management service
  • 520c7b5 Move keepalive out of mgm pkg
  • a6431e0 Update protobuf
  • 551455f Handle keep alive in signal server
  • 70076b9 Fix metadata preparation in signal
  • 649dbf2 Change log line
  • ca1722e Handle the stream sending in thread safe way
  • d68a4a7 Replace the grpc header key to NetBird specific

📊 Changes

12 files changed (+1475 additions, -2049 deletions)

View changed files

📝 client/internal/engine.go (+0 -1)
keepalive/client.go (+5 -0)
keepalive/keep_alive.go (+155 -0)
keepalive/monitor.go (+35 -0)
📝 management/client/grpc.go (+11 -0)
📝 management/cmd/management.go (+8 -1)
📝 management/proto/management.pb.go (+1156 -2016)
📝 management/proto/management.proto (+2 -0)
📝 signal/client/grpc.go (+18 -8)
📝 signal/cmd/run.go (+14 -5)
📝 signal/proto/signalexchange.pb.go (+68 -17)
📝 signal/proto/signalexchange.proto (+3 -1)

📄 Description

Describe your changes

Application level keep alive PoC for gRPC.

The concept is that mgmt server send the keep alive messages
periodically.
Because the current setup does not support the both way communication
the server inject keep alive (empty) messages in the Sync stream. So
the keep alive procedure will start after the Sync call happens.

The application level keep alive will be applied only on that case when the
server is behind reveres proxy. The server check it with the proper
HTTP headers to ensure to necessary this feature or not.

Because in the client has a bug what can cause exception I involved
the version information into the gRPC function calls and the server
send keep alive messages only if it is supported by the client.

Example nginx config:

server {
  listen *:80 http2;

  server_name signal.localhost;

  location / {
    grpc_set_header x-netbird-peer '$remote_addr:$remote_port';
    grpc_pass grpc://0.0.0.0:82;
  }
}

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)
  • Extended the README / documentation, if necessary

🔄 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/771 **Author:** [@pappz](https://github.com/pappz) **Created:** 3/28/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/keep_alive` --- ### 📝 Commits (8) - [`e376541`](https://github.com/netbirdio/netbird/commit/e3765417454338081d62f3afc74e463b07f3ed02) Add grpc keep alive for management service - [`520c7b5`](https://github.com/netbirdio/netbird/commit/520c7b5d3736a5b49a3d23443eb8db6abbf71ed9) Move keepalive out of mgm pkg - [`a6431e0`](https://github.com/netbirdio/netbird/commit/a6431e053b32550627ae2b95944a8cb7bca35f46) Update protobuf - [`551455f`](https://github.com/netbirdio/netbird/commit/551455f3143a5fc5589f0436a6a7de460d998a4a) Handle keep alive in signal server - [`70076b9`](https://github.com/netbirdio/netbird/commit/70076b98d2f1b89582dcc29c1599b7866816ccdf) Fix metadata preparation in signal - [`649dbf2`](https://github.com/netbirdio/netbird/commit/649dbf2bedbab6b7eb0cc2c6e40994e08fb4eafb) Change log line - [`ca1722e`](https://github.com/netbirdio/netbird/commit/ca1722ed10607ad6c6378f945930f74b0d710c9e) Handle the stream sending in thread safe way - [`d68a4a7`](https://github.com/netbirdio/netbird/commit/d68a4a7d21609a2baac78bb24154d2f411338439) Replace the grpc header key to NetBird specific ### 📊 Changes **12 files changed** (+1475 additions, -2049 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/engine.go` (+0 -1) ➕ `keepalive/client.go` (+5 -0) ➕ `keepalive/keep_alive.go` (+155 -0) ➕ `keepalive/monitor.go` (+35 -0) 📝 `management/client/grpc.go` (+11 -0) 📝 `management/cmd/management.go` (+8 -1) 📝 `management/proto/management.pb.go` (+1156 -2016) 📝 `management/proto/management.proto` (+2 -0) 📝 `signal/client/grpc.go` (+18 -8) 📝 `signal/cmd/run.go` (+14 -5) 📝 `signal/proto/signalexchange.pb.go` (+68 -17) 📝 `signal/proto/signalexchange.proto` (+3 -1) </details> ### 📄 Description ## Describe your changes Application level keep alive PoC for gRPC. The concept is that mgmt server send the keep alive messages periodically. Because the current setup does not support the both way communication the server inject keep alive (empty) messages in the Sync stream. So the keep alive procedure will start after the Sync call happens. The application level keep alive will be applied only on that case when the server is behind reveres proxy. The server check it with the proper HTTP headers to ensure to necessary this feature or not. Because in the client has a bug what can cause exception I involved the version information into the gRPC function calls and the server send keep alive messages only if it is supported by the client. Example nginx config: ``` server { listen *:80 http2; server_name signal.localhost; location / { grpc_set_header x-netbird-peer '$remote_addr:$remote_port'; grpc_pass grpc://0.0.0.0:82; } } ``` ## Issue ticket number and link ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <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 02:07:08 -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#12973