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

Fix carelink login error 504 #3029

Merged
merged 1 commit into from
Aug 19, 2023

Conversation

ah7675
Copy link
Contributor

@ah7675 ah7675 commented Aug 19, 2023

xDrip carelink follow gets 504 error whereas Medtronic Carelink app and WebUI is working properly.

08-17 19:23:31.096 32209  5353 D OkHttp  : --> GET https://carelink.minimed.eu/patient/sso/login?country=tw&lang=en
08-17 19:23:31.097 32209  5353 D OkHttp  : Accept-Language: en;q=0.9, *;q=0.8
08-17 19:23:31.097 32209  5353 D OkHttp  : sec-ch-ua: "Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"
08-17 19:23:31.097 32209  5353 D OkHttp  : User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
08-17 19:23:31.097 32209  5353 D OkHttp  : Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
08-17 19:23:31.097 32209  5353 D OkHttp  : Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
08-17 19:23:31.097 32209  5353 D OkHttp  : --> END GET
08-17 19:23:31.144 32209  5353 D OkHttp  : <-- 504 Gateway Time-out https://carelink.minimed.eu/patient/sso/login?country=tw&lang=en (47ms)

@jamorham
Copy link
Collaborator

@benceszasz can you review this thanks

@benceszasz
Copy link
Contributor

@ah7675
I think that the HTTP 504 may occurs because your client (xdrip) gets banned by CareLink, maybe due to the so many unsuccessful requests during CareLink server issues. There are many, who have no issues with the current version and I have also tested with all kinds of accounts and regions and didn't have any issues. At the same time there are some who gets this HTTP 504 error code.
Could you try it again with the current xdrip version?

@ah7675
Copy link
Contributor Author

ah7675 commented Aug 19, 2023

@ah7675 I think that the HTTP 504 may occurs because your client (xdrip) gets banned by CareLink, maybe due to the so many unsuccessful requests during CareLink server issues. There are many, who have no issues with the current version and I have also tested with all kinds of accounts and regions and didn't have any issues. At the same time there are some who gets this HTTP 504 error code. Could you try it again with the current xdrip version?

@benceszasz

Here are tests I did:

  • tested with 20230810-variant4, and debug build based on 20230810.
  • disable collector for 15 mins and then enable again
  • switch between WIFI and LTE
  • change version tag to 115 and then switch back to 112
    • 112 still not work

Note. I didn't use carelink for months, just started few days ago for debugging.

Yes, I do agree that maybe recent outage causes massive retries and eventually Carelink ban certain clients in my region.
But if that's the case, changing version tag seems the only way to solve problem.

BTW, why do you think latest xdrip version may run without problem? I thought it's all the same for version after May.

@benceszasz
Copy link
Contributor

@ah7675 so after changing back to the official version you still get the HTTP 504 error?

I do agree that changing the user agent could solve the banning issue, if that is the case. I am just trying to figure out why certain users gets this HTTP 504 error and trying to find a final solution for such cases, since this has happend during earlier CareLink server outages and the issue disappeared after some time. This seems to be the perfect time for testing, since there are users who have the 504 error.

I recommended the current version, because it is easier to download. BTW the latest changes in the CareLink communication were in June, this is the minimum recommended version for CareLink Follower:
#2914
There was another change in July, but it was just the extension of the possible countries:
#2937

@ah7675
Copy link
Contributor Author

ah7675 commented Aug 19, 2023

@benceszasz

so after changing back to the official version you still get the HTTP 504 error?

Correct, all combinations are failed except the one which has 115 tag in user-agent.

I am just trying to figure out why certain users gets this HTTP 504 error and trying to find a final solution for such cases, since this has happend during earlier CareLink server outages and the issue disappeared after some time. This seems to be the perfect time for testing, since there are users who have the 504 error.

I see. I'm also curious about the root cause.
In my region, there is a T1D community has been suffering from this for a week. Most of people in the community are parents who rely on xDrip to monitor their kids' glucose.

BTW the latest changes in the CareLink communication were in June, this is the minimum recommended version for CareLink Follower:
#2914
There was another change in July, but it was just the extension of the possible countries:
#2937

Got it. But I think they are not relevant, since 504 error is returned by very first SSO endpoint.

In addition, I just tried more combinations with regard to source ip & server ip & country_code.

  1. US source IP (VPN) + 173.222.162.177 (carelink.minimed.eu) + country code = gb
  2. US source IP (VPN) + 173.222.162.177 (carelink.minimed.eu) + country code = tw
  3. TW source IP + 173.222.162.177 (carelink.minimed.eu) + country code = tw
  4. TW source IP + 210.71.227.210 (carelink.minimed.eu) + country code = tw
  5. US source IP (VPN) + 210.71.227.210 (carelink.minimed.eu) + country code = tw
  6. US source IP (VPN) + 210.71.227.210 (carelink.minimed.eu) + country code = gb

All of above failed with 504. Therefore I think this is not region based issue.

curl -v --resolve carelink.minimed.eu:443:210.71.227.210 -H 'Accept-Language: en;q=0.9, *;q=0.8' \
-H 'sec-ch-ua: "Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
'https://carelink.minimed.eu/patient/sso/login?country=tw&lang=en'

It works as long as I change 'Chrome/112.0.0.0' to something else.

@benceszasz
Copy link
Contributor

This is very strange...
For me all regions are working: I am running 10 xdrips (5 offical xdrip + variants & 5 private xdrip version + variants) from home (Hungary) with EU and US accounts using the "old" User-Agent values and I haven't received a single HTTP 504 error.

Copy link
Contributor

@benceszasz benceszasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct update of Chrome user agent version to the latest one. This modification solves the issue of some users who gets an HTTP 504 error.

@benceszasz
Copy link
Contributor

@jamorham
Short code modification: update of Chrome user agent version in the HTTP requests to the latest version number.
This modification solves the issue of some users who gets an HTTP 504 error.
Everything is ok!

Copy link
Collaborator

@jamorham jamorham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that from what I see discussed that this should be merged.

@jamorham jamorham merged commit 406a925 into NightscoutFoundation:master Aug 19, 2023
1 check passed
@ah7675 ah7675 deleted the carelink-504 branch August 20, 2023 11:42
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.

None yet

3 participants