Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android app can't connect if server isn't listening on IPv6 #24703

Open
mattermod opened this issue Oct 3, 2023 · 13 comments · May be fixed by mattermost/mattermost-mobile#8571
Open

Android app can't connect if server isn't listening on IPv6 #24703

mattermod opened this issue Oct 3, 2023 · 13 comments · May be fixed by mattermost/mattermost-mobile#8571
Assignees
Labels
Hacktoberfest Help Wanted Community help wanted

Comments

@mattermod
Copy link
Contributor

https://github.com/mattermost/mattermost-mobile/issues/7576

We recently had the same issue as @n-gao in #6643 (comment)_ – The only thing we saw was that the Android app was having trouble most of the time, while all other apps as well as web browsers (even on Android) did not have any issue, and the only message we got was "failed to connect". This made it pretty hard to debug.

Debian 11 currently has a docker version (20.10.5) which only publishes IPv4 addresses when publishing a port globally (the related GitHub issue can be found here). This means that this faulty configuration could easily be deployed by anyone using Mattermost's official docker installation guide on a Debian 11 server with nginx.

It appears that the iOS app, the Desktop app, as well as web browsers will retry the connection on IPv4 if IPv6 fails, but the Android app doesn't. Hence, the connection issue only in the Android app, and only when it's inside an IPv6-enabled network.

I suggest fixing this issue in the Android app, and until then, adding this to the debugging guideline


If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.

JIRA: https://mattermost.atlassian.net/browse/MM-54703

@GourabSanyal
Copy link

Hi. I would like to work on this issue, please assign it to me.

@ceskyDJ
Copy link

ceskyDJ commented Jan 31, 2024

Hi @GourabSanyal! How is it going? I had problems with IPv6, too, and admins found that the server has AAAA DNS record, but doesn't accept IPv6 connections to the running Mattermost server. One colleague mentioned, that browsers solve this via the Happy Eyeballs algorithm (see https://datatracker.ietf.org/doc/html/rfc8305) – Mattermost works in the web browser on the same device and network. Maybe it could be done here using it, too (in the case you haven't started yet or you haven't already found a better solution).

@GourabSanyal
Copy link

Hi @ceskyDJ , I've created something and will soon submit a PR for it. In the meantime, could you recommend a good testing approach? Thanks!

@ceskyDJ
Copy link

ceskyDJ commented Feb 1, 2024

I propose these test cases based on my problem:

TC 1: Adding a server instance to the app without IPv6 connectivity properly set up

Setup:

  1. Setup Mattermost server available via hostname. Create A and AAAA records for that hostname. Limit server to listen to IPv4 only.
  2. Install Mattermost mobile app on Android phone (Samsung Galaxy S22, Android 14 in my case).
  3. Connect your phone to some dual stack (IPv4 + IPv6) network (Wi-fi or cellular network).

Exercise:
3. Open the Mattermost mobile app and try to add the created Mattermost server instance via hostname.

Verify:
4. Check if the Mattermost server instance is successfully added to the mobile app.

Teardown:
5. Uninstall the Mattermost server instance and the mobile app.

TC 2: Connecting to the Mattermost server instance from the mobile app (already added)

Setup:

  1. Setup Mattermost server available via hostname. Create A and AAAA records for that hostname. Limit server to listen to IPv4 only.
  2. Install Mattermost mobile app on Android phone (Samsung Galaxy S22, Android 14 in my case).
  3. Connect your phone to some IPv4-only network.
  4. Add the Mattermost server instance.
  5. Connect your phone to some dual stack (IPv4 + IPv6) network (Wi-fi or cellular network).

Exercise:
3. Open the Mattermost mobile app, select the tested Mattermost server instance.

Verify:
4. Check if the app successfully connects to the server instance and synchronize messages.

Teardown:
5. Uninstall the Mattermost server instance and the mobile app.

@huyvvbka
Copy link

huyvvbka commented Oct 2, 2024

I am also facing the same problem with my server, have you guys fixed this problem, please let me know the solution if any. Thanks a lot

@wezm
Copy link

wezm commented Jan 14, 2025

I've created something and will soon submit a PR for it. In the meantime, could you recommend a good testing approach? Thanks!

@GourabSanyal did you ever push your changes anywhere? I'd be curious to see how you addressed the issue.

@wezm
Copy link

wezm commented Jan 15, 2025

To add some more detail, I'm encountering this issue on my Android phone (Pixel 8a) as is another Android user on my server. The server is not available over IPv6 and I do not have and AAAA or similar DNS records. The issue only manifests when on mobile data as opposed to Wi-Fi. When on mobile data the phone is using IPv6. The Mattermost app is completely unable to connect to the server, it says "The server is not reachable". However accessing the Mattermost instance in a browser on the same phone works fine.

The following are screenshots from test-ipv6.com. Perhaps it is relevant that the DNS server of my mobile service is not accessible over IPv6:

Image

Image

@GourabSanyal
Copy link

I've created something and will soon submit a PR for it. In the meantime, could you recommend a good testing approach? Thanks!

@GourabSanyal did you ever push your changes anywhere? I'd be curious to see how you addressed the issue.

I stopped working on it way back. I hardly remember anything about solving this at this point, I'd request the maintainer to unassign me.

@rossjackson
Copy link

I recently experienced this with mattermost and also one of my react native app. I am actually testing this solution right now. Just waiting for android approvers to approve my app and I was wondering if I can create a PR for mattermost if this works for me?

I can connect through mattermost and my other app when I'm in wifi but if I am using my mobile data, it takes soooo slow. I can use the browser just fine.

@rossjackson
Copy link

rossjackson commented Feb 7, 2025

I recently experienced this with mattermost and also one of my react native app. I am actually testing this solution right now. Just waiting for android approvers to approve my app and I was wondering if I can create a PR for mattermost if this works for me?

I can connect through mattermost and my other app when I'm in wifi but if I am using my mobile data, it takes soooo slow. I can use the browser just fine.

Just giving update that the link I shared fixed my app problem.

@TheZoker
Copy link

TheZoker commented Feb 7, 2025

@rossjackson Thanks for the hint!
So the solution is to update okhttp3 to 5.0.0?

@rossjackson
Copy link

@rossjackson Thanks for the hint! So the solution is to update okhttp3 to 5.0.0?

Yes! That did the trick for my app! I can't wait for this fix because ive been using the PWA 😭😭

@rossjackson
Copy link

Went ahead and opened a PR because I can't stand the PWA version. I want the mobile app!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest Help Wanted Community help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants