[GH-ISSUE #5432] Client network map not synced after client upgrade causes unexpected disconnection #11205

Open
opened 2026-08-05 01:28:53 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @gamerslouis on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/5432

Describe the problem

The client handles network map update events from the management server.
When a client detects that a remote peer’s agentVersion is different from the one stored locally, it removes and recreates the peer connection.

However, when a NetBird client is upgraded, the agentVersion change does not trigger a network map sync event. As a result, other peers may keep an outdated agentVersion in their network map for an extended period of time.
Once a sync is eventually triggered by other conditions, this mismatch causes the peer connection to be removed and recreated, leading to unexpected disconnections.

A clear and concise description of what the problem is.

To Reproduce

  1. Create two NetBird clients and connect them to each other.
  2. Upgrade client A.
  3. Add and then remove an iptables rule to temporarily disconnect client B from the management server, forcing a sync.
  4. Client B will close and recreate the connection with client A.

Expected behavior

One of the following behaviors would be acceptable:

  • A change in agentVersion should not cause peer reconnection.
  • Or, the network map should be synchronized immediately after a client upgrade so that peers have the correct agentVersion.

Are you using NetBird Cloud?

self-host NetBird control plane

NetBird version

upgrade from 0.51.2 to 0.53.0

Is any other VPN software installed?
No

Additional context

The client closes the peer connection through the following call path:

Engine.handleSync
-> Engine.updateNetworkMap
-> Engine.modifyPeers 
-> Engine.removePeer

Relevant code snippet:

func (e *Engine) modifyPeers(peersUpdate []*mgmProto.RemotePeerConfig) error {

	// first, check if peers have been modified
	var modified []*mgmProto.RemotePeerConfig
	for _, p := range peersUpdate {
                 ...
		if currentPeer.AgentVersionString() != p.AgentVersion {
			modified = append(modified, p)
			continue
		}
                 ...
       }

      	for _, p := range modified {
		err := e.removePeer(p.GetWgPubKey())
		if err != nil {
			return err
		}
	}
        ...
}

The client compares AgentVersion, and when a difference is detected, it calls removePeer.

However, after a remote peer is upgraded or restarted, no sync event is sent to other peers, because currently only the following events for peer updates trigger networkMapController.OnPeersUpdated:
• Peer IP change (UpdatePeerIP)
• Peer reconnection after expiration (MarkPeerConnected)

As a result, the outdated agentVersion remains in the network map until a sync is triggered by unrelated events, at which point the peer connection is unexpectedly recreated.

Have you tried these troubleshooting steps?

  • Reviewed client troubleshooting (if applicable)
  • Checked for newer NetBird versions
  • Searched for similar issues on GitHub (including closed ones)
  • Restarted the NetBird client
  • Disabled other VPN software
  • Checked firewall settings
Originally created by @gamerslouis on GitHub (Feb 24, 2026). Original GitHub issue: https://github.com/netbirdio/netbird/issues/5432 **Describe the problem** The client handles network map update events from the management server. When a client detects that a remote peer’s agentVersion is different from the one stored locally, it removes and recreates the peer connection. However, when a NetBird client is upgraded, the agentVersion change **does not trigger a network map sync event**. As a result, other peers may keep an outdated agentVersion in their network map for an extended period of time. Once a sync is eventually triggered by other conditions, this mismatch causes the peer connection to be removed and recreated, leading to unexpected disconnections. A clear and concise description of what the problem is. **To Reproduce** 1. Create two NetBird clients and connect them to each other. 2. Upgrade client A. 3. Add and then remove an iptables rule to temporarily disconnect client B from the management server, forcing a sync. 4. Client B will close and recreate the connection with client A. **Expected behavior** One of the following behaviors would be acceptable: + A change in agentVersion should not cause peer reconnection. + Or, the network map should be synchronized immediately after a client upgrade so that peers have the correct agentVersion. **Are you using NetBird Cloud?** self-host NetBird control plane **NetBird version** upgrade from 0.51.2 to 0.53.0 **Is any other VPN software installed?** No **Additional context** The client closes the peer connection through the following call path: ``` Engine.handleSync -> Engine.updateNetworkMap -> Engine.modifyPeers -> Engine.removePeer ``` Relevant code snippet: ``` func (e *Engine) modifyPeers(peersUpdate []*mgmProto.RemotePeerConfig) error { // first, check if peers have been modified var modified []*mgmProto.RemotePeerConfig for _, p := range peersUpdate { ... if currentPeer.AgentVersionString() != p.AgentVersion { modified = append(modified, p) continue } ... } for _, p := range modified { err := e.removePeer(p.GetWgPubKey()) if err != nil { return err } } ... } ``` The client compares AgentVersion, and when a difference is detected, it calls removePeer. However, after a remote peer is upgraded or restarted, no sync event is sent to other peers, because currently only the following events for peer updates trigger networkMapController.OnPeersUpdated: • Peer IP change (UpdatePeerIP) • Peer reconnection after expiration (MarkPeerConnected) As a result, the outdated agentVersion remains in the network map until a sync is triggered by unrelated events, at which point the peer connection is unexpectedly recreated. **Have you tried these troubleshooting steps?** - [X] Reviewed [client troubleshooting](https://docs.netbird.io/how-to/troubleshooting-client) (if applicable) - [X] Checked for newer NetBird versions - [X] Searched for similar issues on GitHub (including closed ones) - [X] Restarted the NetBird client - [X] Disabled other VPN software - [X] Checked firewall settings
saavagebueno added the triage-needed label 2026-08-05 01:28:53 -04:00
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#11205