Skip to content

Conversation

cargodog
Copy link

@cargodog cargodog commented Aug 29, 2025

This PR adds a warning if Nostr relays cannot be reached. This resolves #322

There are existing build errors on main, so I am unable to test. Happy to test once those are resolved.

[edit] The original issue asks for a permission check. That is not possible, as there is no API to check the network permission. The best we can do is detect disconnection (ALL relays unreachable) and prompt the user to check their connection settings.

- Add static callback for reporting network errors to UI
- Will be used to display system messages when network operations fail
@callebtc
Copy link
Collaborator

cool thank you! this is nice but it's not exactly what the issue is about. nostr relays could be unreachable due to many different reasons, but network permissions should be checked in all cases.

@cargodog
Copy link
Author

@callebtc I added more context in the original issue, but the problem is the network permission cannot be checked, by design.

Network is not a permission on normal Android, and GrapheneOS has added the network toggle at a lower level than Android's permission system intentionally, so that apps cannot distinguish between the permission being denied by the user or internet being unavailable for any other normal reason.

So, unfortunately, I think the only thing we can do is detect a connection failure and prompt the user to ensure the device (and app for Graphene users) has an internet connection.

@cargodog
Copy link
Author

nostr relays could be unreachable due to many different reasons

Also, notice this message only appears if all Nostr relays are unreachable. Its totally expected that some relays will be unreachable, but if all relays are unreachable, then the user has a connectivity problem, right?

@callebtc
Copy link
Collaborator

nostr relays could be unreachable due to many different reasons

Also, notice this message only appears if all Nostr relays are unreachable. Its totally expected that some relays will be unreachable, but if all relays are unreachable, then the user has a connectivity problem, right?

that's maybe a reasonable assumption but it's not what the issue above is about. you might just have lost wifi.

@cargodog
Copy link
Author

cargodog commented Aug 31, 2025

that's maybe a reasonable assumption but it's not what the issue above is about. you might just have lost wifi.

Yes, and in this case I still think its reasonable to inform the user Bitchat may not behave as expected, because it doesnt have a connection. The entire point is that we cannot know WHY there is no internet, but at least we can tell the user things won't behave well until we have internet 🤷

What behavior would you prefer to see?

@callebtc
Copy link
Collaborator

callebtc commented Sep 9, 2025

it could be many things:

  • network permissions (this should be detectable?)
  • tor down
  • wifi off
  • nostr relays down
  • something else

@callebtc
Copy link
Collaborator

callebtc commented Sep 9, 2025

the build seems to fail, could you check?

@cargodog cargodog force-pushed the network-permission-warning branch 3 times, most recently from 3683586 to e896436 Compare September 10, 2025 03:57
@cargodog
Copy link
Author

No, network permission is not detectable.

My idea was to detect the case when we cannot reach any relays, and assume this means we have SOME network problem (could be any reason). Then I let the user know that there is a network problem and they should check permissions, connection, etc.

My question remains: if not this, what solution do you want to see?

the build seems to fail, could you check?

Something was broken master when I opened the PR. It shouldn't be a problem now that main is fixed. The rebase isn't easy though, because the nostr connection logic has changed significantly. I want to make sure you actually like my proposal, before I go and do that work.

…ager

- Detect network-related exceptions (DNS, connection refused, etc.)
- Report network error via callback (only once per session)
- Add flag to prevent spamming error messages
- Reset error flag on successful sends
- Define NETWORK_ERROR_MESSAGE constant to avoid message duplication
- Set network error callback when initializing Nostr integration
- Display network errors as system messages in chat
- Messages appear greyed out like other system messages
@cargodog cargodog force-pushed the network-permission-warning branch from e896436 to ca6a786 Compare September 10, 2025 04:14
@cargodog
Copy link
Author

I have reset the branch to where it was before I attempted the rebase, since the rebase ended up being a lot more work than anticipated. This way you can review my idea from the original PR.

If you like the idea, then I will do the work of rebasing it and fixing the any errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvement: check for network permissions and guide the user to turn it on

2 participants