mattermost / mattermost-mobile

Next generation iOS and Android apps for Mattermost in React Native
https://about.mattermost.com/
Apache License 2.0
2.25k stars 1.36k forks source link

Mobile app - Android/OS applications does not connect to self hosted server #7004

Closed chrisult87 closed 1 year ago

chrisult87 commented 1 year ago

Summary

New mobile app version 2.0.0 does not connect to self hosted server. Connects fine through app version 1.55.1. Mattermost Server has just been upgraded from 7.0.0 to 7.7.0.

Environment Information

Steps to reproduce

  1. Download/upgrade the mobile app from Play Store/App Store.
  2. Enter the URL of the self hosted server. (using HTTPS)
  3. Type in the display name.
  4. Press connect

Expected behavior

App should connect to the server and go to login to account screen.

Observed behavior (that appears unintentional)

"Cannot connect to the server" is displayed. Screenshot_20230123_162320_Mattermost

amyblais commented 1 year ago

@chrisult87 Do the troubleshooting docs help in this case https://docs.mattermost.com/deploy/mobile-troubleshoot.html#i-keep-getting-a-message-cannot-connect-to-the-server-please-check-your-server-url-and-internet-connection?

chrisult87 commented 1 year ago

@amyblais - I had a look at that doco, but I don't see anything similar to the issue I am having.

All was working fine on mobile version 1.55.1. The issue started after users started getting the app updated to 2.0.0.

larkox commented 1 year ago

@chrisult87 A difference between V1 and V2 is that V1 defaulted to ipv4 while V2 defaults to ipv6. A bad configuration in the server for ipv6 may cause this issue. Have you doublechecked (using SSL Labs tool for example) that everything is correct on the SSL side of things?

If that is not the issue, I could try to join the server myself and see if I can debug the issue. You can send me the server link by DM through our community server.

chrisult87 commented 1 year ago

@larkox - we found the issue.

It was the user header configured on the ingress controller preventing the new mattermost client from being allowed through.

larkox commented 1 year ago

@chrisult87 Glad you found the solution!

Just to make sure, I understand the issue was on your side, related to the configuration of your environment, right? So there is nothing we can do to alleviate this in the future. Or is there anything we can do to improve the experience?

Davka commented 1 year ago

@chrisult87 I'm also interested in the solution!

mbonino commented 1 year ago

Hello,

having the same issue with a self-hosted instance running version 7.1.4

Mobile client running version < 2.0 can connect to the server.

Eveything is correct on the SSL side ( A+ on ssllabs)

Mattermost is served from a sub path, "MM_SERVICESETTINGS_SITEURL=https://mydomain/mycompany/mattermost",

I guess the mobile app is confused by the subpath because looking at the reverse proxy logs I can see it is not calling the correct API endpoint, i.e. /mycompany/mycompany/mattermost instead of /mycompany/mattermost:

93.23.13.109 mydomain - [25/Jan/2023:09:13:07 +0000] "HEAD /mycompany/mattermost HTTP/1.1" 302 0 "-" "okhttp/4.9.2" "-"
93.23.13.109 mydomain - [25/Jan/2023:09:13:07 +0000] "HEAD /mycompany/mattermost/ HTTP/1.1" 405 0 "-" "okhttp/4.9.2" "-"
2023/01/25 09:13:08 [error] 159371#159371: *215999 access forbidden by rule, client: 93.23.13.109, server: mydomain, request: "GET /mycompany/mycompany/mattermost/api/v4/system/ping?time=1674637989495 HTTP/1.1", host: "mydomain"
93.23.13.109 mydomain - [25/Jan/2023:09:13:08 +0000] "GET /mycompany/mycompany/mattermost/api/v4/system/ping?time=1674637989495 HTTP/1.1" 403 146 "-" "Mattermost Mobile/2.0.0+6000452 (Android; 8.0.0; PRA-LX1)" "-"
93.23.13.109 - - [25/Jan/2023:09:13:08 +0000] "HEAD /mycompany/mattermost HTTP/1.1" 301 0 "-" "okhttp/4.9.2" "-"
93.23.13.109 mydomain - [25/Jan/2023:09:13:08 +0000] "HEAD /mycompany/mattermost HTTP/1.1" 302 0 "-" "okhttp/4.9.2" "-"
93.23.13.109 mydomain - [25/Jan/2023:09:13:08 +0000] "HEAD /mycompany/mattermost/ HTTP/1.1" 405 0 "-" "okhttp/4.9.2" "-"
2023/01/25 09:13:09 [error] 159371#159371: *216003 access forbidden by rule, client: 93.23.13.109, server: mydomain, request: "GET /mycompany/mycompany/mattermost/api/v4/system/ping?time=1674637989907 HTTP/1.1", host: "mydomain"
93.23.13.109 mydomain - [25/Jan/2023:09:13:09 +0000] "GET /mycompany/mycompany/mattermost/api/v4/system/ping?time=1674637989907 HTTP/1.1" 403 146 "-" "Mattermost Mobile/2.0.0+6000452 (Android; 8.0.0; PRA-LX1)" "-"
mbonino commented 1 year ago

as a workaround, I wrote a Nginx rewrite.

location /mycompany/mycompany/mattermost {
    rewrite ^/mycompany(.*)$ $1 last;
}
enahum commented 1 year ago

as a workaround, I wrote a Nginx rewrite.


location /mycompany/mycompany/mattermost {

    rewrite ^/mycompany(.*)$ $1 last;

}

Hey @mbonino would you mind sharing the domain over a DM so I can take a look and remove the need for the rewrite? Thanks.

My usename is community is @elias

chrisult87 commented 1 year ago

Our issue was..

V1 - user-agent header was returning something like the bellow

"Mozilla/5.0 (Linux; Android 12; M2012K11G Build/SKQ1.211006.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/108.0.5359.128 Mobile Safari/537.36"

V2 - started returning

"Mattermost Mobile/2.0.0+6000452 (Android; 12; M2012K11G)"

In the nginx we had this code which worked fine with V1 but did not with V2 since it was only returning "Mobile" and not "Build"

if ($is_mobile_app = "Mobile+Build" ){ set $allow_mattermost true; }

we changed to the below and then managed to connect the server

if ($http_user_agent ~* "(Mattermost Mobile)" ){ set $allow_mattermost true; }

enahum commented 1 year ago

So this is issue is actually configuration on your end? Should we close it?

chrisult87 commented 1 year ago

Hi @enahum, yes this issue can be closed.

Thanks all.