ios-client cannot be in Connected state after switching to the background. #830

Closed
opened 2025-11-20 05:18:15 -05:00 by saavagebueno · 16 comments
Owner

Originally created by @jiangslee on GitHub (Apr 28, 2024).

Describe the problem

Sorry for posting an issue here (the same issue has been posted in the ios-client repository).

After opening Netbird ios-client on my iPhone and switching to other apps, Netbird ios-client seems to automatically close and disconnect.

I don't find an option in the iPhone settings for the Netbird client to keep refreshing in the background. Sadly, this affects the network I use netbird on my iPhone.

I don’t know if anyone has encountered a similar situation.

How to solve it?

To Reproduce

Steps to reproduce the behavior:

  1. Open Netbird ios client on my iPhone
  2. Click ‘Connect’ and see that the status shows Connected
  3. Switch to other apps to use
  4. After about 10 seconds, switch back to the Netbird ios client and it will display as Disconnected

Expected behavior

Netbird ios client can be in Connected state.

Are you using NetBird Cloud?

self-host.

NetBird version

netbird version

ios-client 0.0.3
ios 17.4.1

NetBird status -d output:

Not applicable in ios-client

Screenshots

https://github.com/netbirdio/netbird/assets/27892476/ebe8dfc9-0e90-45a3-8fa6-4444b2bd641e

image

Additional context

https://github.com/netbirdio/ios-client/issues/9

Originally created by @jiangslee on GitHub (Apr 28, 2024). **Describe the problem** Sorry for posting an issue here (the same issue has been posted in the ios-client repository). After opening Netbird ios-client on my iPhone and switching to other apps, Netbird ios-client seems to automatically close and disconnect. I don't find an option in the iPhone settings for the Netbird client to keep refreshing in the background. Sadly, this affects the network I use netbird on my iPhone. I don’t know if anyone has encountered a similar situation. How to solve it? **To Reproduce** Steps to reproduce the behavior: 1. Open Netbird ios client on my iPhone 2. Click ‘Connect’ and see that the status shows Connected 3. Switch to other apps to use 4. After about 10 seconds, switch back to the Netbird ios client and it will display as `Disconnected` **Expected behavior** Netbird ios client can be in `Connected` state. **Are you using NetBird Cloud?** self-host. **NetBird version** `netbird version` ios-client 0.0.3 ios 17.4.1 **NetBird status -d output:** Not applicable in ios-client **Screenshots** https://github.com/netbirdio/netbird/assets/27892476/ebe8dfc9-0e90-45a3-8fa6-4444b2bd641e ![image](https://github.com/netbirdio/netbird/assets/27892476/279c4d19-0ee3-442a-be7d-4994165eea4f) **Additional context** https://github.com/netbirdio/ios-client/issues/9
saavagebueno added the waiting-feedbacktriage-needed labels 2025-11-20 05:18:15 -05:00
Author
Owner

@jiangslee commented on GitHub (May 10, 2024):

EXC_RESOURCE -> NetbirdNetworkExtension[5634] exceeded mem limit: ActiveHard 50 MB (fatal)

I connected to my iPhone 12 and got the console log. It seems that my iPhone 12 has insufficient running memory, causing the kernel to kill the background process.

image image
@jiangslee commented on GitHub (May 10, 2024): EXC_RESOURCE -> NetbirdNetworkExtension[5634] exceeded mem limit: ActiveHard 50 MB (fatal) I connected to my iPhone 12 and got the console log. It seems that my iPhone 12 has insufficient running memory, causing the kernel to kill the background process. <img width="1232" alt="image" src="https://github.com/netbirdio/netbird/assets/27892476/50bf5e75-2633-44b1-88a9-64c551901fd3"> <img width="1234" alt="image" src="https://github.com/netbirdio/netbird/assets/27892476/14511f63-2fce-4e6b-b931-e4bd1b48482c">
Author
Owner

@mlsmaycon commented on GitHub (May 11, 2024):

Hello @jiangslee, this shouldn't be the case. To help us understand better the case, can you update the app to the latest version, enable trace logs, and export them by accessing the Advanced menu of NetBird's app?

@mlsmaycon commented on GitHub (May 11, 2024): Hello @jiangslee, this shouldn't be the case. To help us understand better the case, can you update the app to the latest version, enable trace logs, and export them by accessing the Advanced menu of NetBird's app?
Author
Owner

@jiangslee commented on GitHub (May 11, 2024):

Hello @mlsmaycon, Thank you very much for paying attention to this problem of mine.

I have updated to the latest version 0.0.4 and enabled Trace Logs, but I did not see any logs file.

image
image

@jiangslee commented on GitHub (May 11, 2024): Hello @mlsmaycon, Thank you very much for paying attention to this problem of mine. I have updated to the latest version 0.0.4 and enabled Trace Logs, but I did not see any logs file. ![image](https://github.com/netbirdio/netbird/assets/27892476/49645883-d05c-41af-859e-51d1f3488662) ![image](https://github.com/netbirdio/netbird/assets/27892476/7a308387-fd5e-4de4-8ad4-df1fa011a694)
Author
Owner

@mlsmaycon commented on GitHub (May 11, 2024):

You need to click on share logs, that will let you choose a path in your device to store the logs which then you can use to share them with us.

@mlsmaycon commented on GitHub (May 11, 2024): You need to click on share logs, that will let you choose a path in your device to store the logs which then you can use to share them with us.
Author
Owner

@jiangslee commented on GitHub (May 11, 2024):

The console Logs show that there are some deny records, but I was not prompted for authorization.

Do I need to enable any settings on my iPhone?

image
@jiangslee commented on GitHub (May 11, 2024): The console Logs show that there are some deny records, but I was not prompted for authorization. Do I need to enable any settings on my iPhone? <img width="1248" alt="image" src="https://github.com/netbirdio/netbird/assets/27892476/d83ea167-00c3-4844-83b1-ccbae4b618a2">
Author
Owner

@jiangslee commented on GitHub (May 11, 2024):

EXC_RESOURCE -> NetbirdNetworkExtension[6591] exceeded mem limit: ActiveHard 50 MB (fatal)

image
@jiangslee commented on GitHub (May 11, 2024): EXC_RESOURCE -> NetbirdNetworkExtension[6591] exceeded mem limit: ActiveHard 50 MB (fatal) <img width="1239" alt="image" src="https://github.com/netbirdio/netbird/assets/27892476/c7b98d06-f42f-4d85-933b-8d3aee7e9754">
Author
Owner

@jiangslee commented on GitHub (May 11, 2024):

**choose a path in your device to store the logs **
sorry , I just got it

@jiangslee commented on GitHub (May 11, 2024): **choose a path in your device to store the logs ** sorry , I just got it
Author
Owner

@jiangslee commented on GitHub (May 11, 2024):

@mlsmaycon I’ve sent you the log file on Slack

@jiangslee commented on GitHub (May 11, 2024): @mlsmaycon I’ve sent you the log file on Slack
Author
Owner

@KortanZ commented on GitHub (May 13, 2024):

Same problem. IOS app become quite unusable these days. I can't recall since when, maybe after upgrade IOS version to 17.4, connection will lost when netbird app are background. Repeat switch foreground reconnect and switch background auto disconnect 3 or 4 times, connection seems could stable for a while. Situation became worse recently, needs more retry.

@KortanZ commented on GitHub (May 13, 2024): Same problem. IOS app become quite unusable these days. I can't recall since when, maybe after upgrade IOS version to 17.4, connection will lost when netbird app are background. Repeat switch foreground reconnect and switch background auto disconnect 3 or 4 times, connection seems could stable for a while. Situation became worse recently, needs more retry.
Author
Owner

@jiangslee commented on GitHub (May 14, 2024):

@KortanZ How many peers you have?
The temporary solution is to modify the peers accessible to the iPhone in Access Control Prolicies. Currently, my iPhone only allows 7 peers to communicate with each other. After switching to the background, the normal connection can still be maintained.

I have sent the logs to the Netbird team via slack, hoping they can find a solution.

In addition, I searched for relevant information. The possible reason is that network extension (tunnel) has memory limitations in iOS.
https://developer.apple.com/forums/thread/73148?page=2

for tunnel providers it seems to be 50 MB now.
Indeed. That’s a big bump!

Anyway, here’s what I see on iOS 15.0:

Provider Limit (MiB)
packet tunnel 50
app proxy 15
filter control 12
filter data 6
DNS proxy 15
app push 24
And, just so we’re clear:

IMPORTANT These limits have changed in the past and may well change in the future. I'm posting them to assist in your debugging. You should not hard code knowledge about these limits into your code. The only way to ensure that your provider can run within the system's memory limits is to thoroughly test it on a wide range of device and OS combinations.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@jiangslee commented on GitHub (May 14, 2024): @KortanZ How many peers you have? The temporary solution is to modify the peers accessible to the iPhone in Access Control Prolicies. Currently, my iPhone only allows 7 peers to communicate with each other. After switching to the background, the normal connection can still be maintained. I have sent the logs to the Netbird team via slack, hoping they can find a solution. In addition, I searched for relevant information. The possible reason is that network extension (tunnel) has memory limitations in iOS. https://developer.apple.com/forums/thread/73148?page=2 >> for tunnel providers it seems to be 50 MB now. > Indeed. That’s a big bump! > > Anyway, here’s what I see on iOS 15.0: > > Provider Limit (MiB) > packet tunnel 50 > app proxy 15 > filter control 12 > filter data 6 > DNS proxy 15 > app push 24 > And, just so we’re clear: > > IMPORTANT These limits have changed in the past and may well change in the future. I'm posting them to assist in your debugging. You should not hard code knowledge about these limits into your code. The only way to ensure that your provider can run within the system's memory limits is to thoroughly test it on a wide range of device and OS combinations. > > Share and Enjoy > — > Quinn “The Eskimo!” @ Developer Technical Support @ Apple > let myEmail = "eskimo" + "1" + "@" + "apple.com"
Author
Owner

@KortanZ commented on GitHub (May 14, 2024):

Really thanks for help! @jiangslee

How many peers you have?

total peers are around over 20, active peers may around 4 to 10.

And i just upgrade ios to version 17.5, and situation is way much better. Connection will last a long period and only disconnet if app go background for quite a while. May be something wrong with my own server's reverse proxy configurition which cause gRPC timeout. I'm using Caddy with a really simple config. I'll use official nginx config to have a try to see if there any different happened.

@KortanZ commented on GitHub (May 14, 2024): Really thanks for help! @jiangslee > How many peers you have? total peers are around over 20, active peers may around 4 to 10. And i just upgrade ios to version 17.5, and situation is way much better. Connection will last a long period and only disconnet if app go background for quite a while. May be something wrong with my own server's reverse proxy configurition which cause gRPC timeout. I'm using Caddy with a really simple config. I'll use official nginx config to have a try to see if there any different happened.
Author
Owner

@jiangslee commented on GitHub (May 18, 2024):

@pascal-fischer Thanks for your hard work.

@jiangslee commented on GitHub (May 18, 2024): @pascal-fischer Thanks for your hard work.
Author
Owner

@KortanZ commented on GitHub (Oct 21, 2024):

@pascal-fischer hi, after #1981 , netbird ios client works well on my ios 17 device, but after update to ios 18.0 recently, the issue raise again, which connection will lost after i switch client to background.

@KortanZ commented on GitHub (Oct 21, 2024): @pascal-fischer hi, after #1981 , netbird ios client works well on my ios 17 device, but after update to ios 18.0 recently, the issue raise again, which connection will lost after i switch client to background.
Author
Owner

@jiangslee commented on GitHub (Oct 21, 2024):

@KortanZ @pascal-fischer This bug seems to have not been fixed yet. I currently limit the number of peers that can connect to each other through policies to ensure that Netbird can be used temporarily under iOS.

@jiangslee commented on GitHub (Oct 21, 2024): @KortanZ @pascal-fischer This bug seems to have not been fixed yet. I currently limit the number of peers that can connect to each other through policies to ensure that Netbird can be used temporarily under iOS.
Author
Owner

@nazarewk commented on GitHub (Apr 28, 2025):

Hello @jiangslee,

We're currently reviewing our open issues and would like to verify if this problem still exists in the latest NetBird version.

Could you please confirm if the issue is still there?

We may close this issue temporarily if we don't hear back from you within 2 weeks, but feel free to reopen it with updated information.

Thanks for your contribution to improving the project!

@nazarewk commented on GitHub (Apr 28, 2025): Hello @jiangslee, We're currently reviewing our open issues and would like to verify if this problem still exists in the [latest NetBird version](https://github.com/netbirdio/netbird/releases). Could you please confirm if the issue is still there? We may close this issue temporarily if we don't hear back from you within **2 weeks**, but feel free to reopen it with updated information. Thanks for your contribution to improving the project!
Author
Owner

@mlsmaycon commented on GitHub (Jun 1, 2025):

closing issue due to no recent feedback. Feel free to open a new one if the issue persist or reopen if this was a feature request.

@mlsmaycon commented on GitHub (Jun 1, 2025): closing issue due to no recent feedback. Feel free to open a new one if the issue persist or reopen if this was a feature request.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#830