BHSPitMonkey / homeassistant-garmin-mapshare

Home Assistant custom integration for Garmin MapShare feeds
MIT License
6 stars 1 forks source link

Empty RSS feed response #4

Closed Figure-itout closed 6 months ago

Figure-itout commented 6 months ago

I live in The Netherlands, try to add someones mapshare-address. But get an error about empty response.

Logger: custom_components.garmin_mapshare.config_flow Source: custom_components/garmin_mapshare/config_flow.py:67 Integration: Garmin MapShare (documentation, issues) First occurred: 20:13:12 (1 occurrences) Last logged: 20:13:12

Unexpected exception Traceback (most recent call last): File "/config/custom_components/garmin_mapshare/config_flow.py", line 67, in async_step_user info = await validate_input(self.hass, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/garmin_mapshare/config_flow.py", line 41, in validate_input if not await hub.authenticate(): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/garmin_mapshare/kml_fetch.py", line 39, in authenticate devices = await self.fetch_data() ^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/garmin_mapshare/kml_fetch.py", line 60, in fetch_data raise ValueError( ValueError: Received empty response from https://explore.garmin.com/Feed/Share/reXXXXXXXXXXXXX using auth: True

If I open the url with :PASSWORD in front of the HOST, I also get an empty result. If I open the mapshare-page in the browser to take a look at the tracks, I only got data from share.garmin.com and nothing from explore.garmin.com.

If I try to add the integration with a wrong password, I got the same error.

BHSPitMonkey commented 6 months ago

Can you go to the integration in HACS, select "Redownload" from the menu, and choose "main" as the version, and then restart HA and try again?

On Wed, Jan 3, 2024, 11:32 Figure-itout @.***> wrote:

I live in The Netherlands, try to add someones mapshare-address. But get an error about empty response.

Logger: custom_components.garmin_mapshare.config_flow Source: custom_components/garmin_mapshare/config_flow.py:67 Integration: Garmin MapShare (documentation https://github.com/BHSPitMonkey/homeassistant-garmin-mapshare#readme, issues https://github.com/BHSPitMonkey/homeassistant-garmin-mapshare/issues) First occurred: 20:13:12 (1 occurrences) Last logged: 20:13:12

Unexpected exception Traceback (most recent call last): File "/config/custom_components/garmin_mapshare/config_flow.py", line 67, in async_step_user info = await validate_input(self.hass, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/garmin_mapshare/config_flow.py", line 41, in validate_input if not await hub.authenticate(): ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/garmin_mapshare/kml_fetch.py", line 39, in authenticate devices = await self.fetch_data() ^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/garmin_mapshare/kml_fetch.py", line 60, in fetch_data raise ValueError( ValueError: Received empty response from https://explore.garmin.com/Feed/Share/reXXXXXXXXXXXXX using auth: True

If I open the url with :PASSWORD in front of the HOST, I also get an empty result. If I open the mapshare-page in the browser to take a look at the tracks, I only got data from share.garmin.com and nothing from explore.garmin.com.

If I try to add the integration with a wrong password, I got the same error.

— Reply to this email directly, view it on GitHub https://github.com/BHSPitMonkey/homeassistant-garmin-mapshare/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIHCD2CPIREVUOAOT5JILYMWW33AVCNFSM6AAAAABBL4PLQGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DINJUGQYDKNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Figure-itout commented 6 months ago

I tried the main version but got the same error.

Ichijoe2112 commented 6 months ago

Hi I'm not sure if it belongs here, but as my problem seems related I didn't want to open another Ticket. I'm a *n00b to has.io (As oppoesd to the Docker versions, that do not have direct access to HACS or these Addd-ons. So I don't know if its me, or not.

As it is I can not use my account share.garmin.com/Ichijoe + "MyPass", as it always returns "Unexpected Error", The other Garmin Connect Addon, for HA is working fine, with my eMail + Pass

*Any hints as to where (Or how), I can dig into the debug setting(s) would be appreciated,

Figure-itout commented 6 months ago

You can find the logs here (have to translate it from Dutch): Settings -> System -> Logs Here you can find the error of mapshare. Click on it for the details.

BHSPitMonkey commented 6 months ago

HACS works fine via Docker; That's the way I use it every day.

This integration does not use the username/password from your Garmin account, it uses the separate link name and password meant for sharing with friends and family in your MapShare settings.

To enable debug logging, try visiting YOURINSTANCE/config/integrations/integration/garmin_mapshare, click "Enable Debug Logging" there, and then view your logs in Settings > System > Logs after triggering another failure.

BHSPitMonkey commented 6 months ago

Version v1.0.1 is now released, with better logging / error handling messages. Give it a try (again, with Debug Logging enabled) and hopefully we can tell what's going on.

If there are still problems, and you're seeing your MapShare name/password function correctly on https://share.garmin.com/LINK_NAME_HERE, you can email me with your MapShare link name (and a temporary password, not your normal one) and I can try to reproduce the issue on my end (if you don't mind me potentially knowing where your inReach has been). My email can be found in the commit log.

Figure-itout commented 6 months ago

Thank you for the update. The error I get is: Server returned an empty response. This usually means the MapShare link name is not valid. Make sure you can successfully visit this map at: https://share.garmin.com/LINK_NAME_HERE

Debug logging doesn't show in the integration. I guess because a lack of an entity.

Can I use the e-mailadres at your old, unmaintained website?

miggland commented 6 months ago

I see the same behaviour as @Figure-itout

When I do this: curl -sv https://:MYPASSWORD@share.garmin.com/share/XXXXX

I get this response:

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/mapshare/XXXXX/Map/MapSharePassword?url=XXXXX">here</a>.</h2>
<script defer src="https://static.cloudflareinsights.com/beacon.min.js/v84a3a4012de94ce1a686ba8c167c359c1696973893317" integrity="sha512-euoFGowhlaLqXsPWQ48qSkBSCFs3DPRyiwVu3FjR96cMPx+Fr+gpWRhIafcHwqwCqWS42RZhIudOvEI+Ckf6MA==" data-cf-beacon='{"rayId":"84156c3a655024c2","b":1,"version":"2023.10.0","token":"db1111111dc79e943f7a1111f0a1111111b"}' crossorigin="anonymous"></script>
</body></html>

Header:

*   Trying 104.19.148.28:443...
* Connected to share.garmin.com (104.19.148.28) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS header, Certificate Status (22):
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.2 (IN), TLS header, Finished (20):
{ [5 bytes data]
* TLSv1.2 (IN), TLS header, Supplemental data (23):
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
{ [19 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [2321 bytes data]
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
{ [80 bytes data]
* TLSv1.3 (IN), TLS handshake, Finished (20):
{ [52 bytes data]
* TLSv1.2 (OUT), TLS header, Finished (20):
} [5 bytes data]
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Finished (20):
} [52 bytes data]
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
*  start date: May 18 00:00:00 2023 GMT
*  expire date: May 17 23:59:59 2024 GMT
*  subjectAltName: host "share.garmin.com" matched cert's "share.garmin.com"
*  issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
} [5 bytes data]
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
} [5 bytes data]
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
} [5 bytes data]
* Server auth using Basic with user ''
* Using Stream ID: 1 (easy handle 0x556dd6e61e90)
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
} [5 bytes data]
> GET /share/XXXXX HTTP/2
> Host: share.garmin.com
> authorization: Basic OlaaaaaaaaaaaaaaaaaaaaAAAA==
> user-agent: curl/7.81.0
> accept: */*
> 
* TLSv1.2 (IN), TLS header, Supplemental data (23):
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [230 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [230 bytes data]
* old SSL session ID is stale, removing
* TLSv1.2 (IN), TLS header, Supplemental data (23):
{ [5 bytes data]
* TLSv1.2 (OUT), TLS header, Supplemental data (23):
} [5 bytes data]
* TLSv1.2 (IN), TLS header, Supplemental data (23):
{ [5 bytes data]
< HTTP/2 302 
< date: Sat, 06 Jan 2024 16:43:56 GMT
< content-type: text/html; charset=utf-8
< location: /mapshare/XXXX/Map/MapSharePassword?url=XXXX
< cf-ray: 84156c35e97324c2-ZRH
< cf-cache-status: MISS
< cache-control: private
< set-cookie: BrowsingMode=Desktop; path=/
< vary: Accept-Encoding
< access-control-expose-headers: Request-Context
< cf-worker-proxied: https://eur-share.explore.garmin.com/share/XXXX
< cf-worker-region-time: 687
< cf-worker-response-time: 826
< request-context: appId=cid-v1:90d291b6-47e4-4a61-9ca1-baacfc608eaa
< x-powered-by: ASP.NET
< x-ua-compatible: IE=edge
< set-cookie: __cf_bm=...=; path=/; expires=Sat, 06-Jan-24 17:13:56 GMT; domain=.share.garmin.com; HttpOnly; Secure; SameSite=None
< server: cloudflare
< 
* TLSv1.2 (IN), TLS header, Supplemental data (23):
{ [5 bytes data]
* TLSv1.2 (IN), TLS header, Supplemental data (23):
{ [5 bytes data]
* Connection #0 to host share.garmin.com left intact

If I do this: curl -sv https://:MYPASSWORD@eur-share.explore.garmin.com/Feed/Share/XXXXX I get a result which looks like a sensible KML file.

BHSPitMonkey commented 6 months ago

@miggland Thanks! What happens when you drop the eur-share. part from that final URL (thus mimicking the request the integration makes)? Is there any indication in the response body/headers that suggests the need for a region-specific subdomain?

BHSPitMonkey commented 6 months ago

Progress! I was able to find a public MapShare feed based in Europe (side note, this guy is pretty extreme!) and learned that while accessing its feed using https://explore.garmin.com leads to an empty response, accessing its feed (or any other?) using https://share.garmin.com works as expected. There is probably some server-side logic that proxies requests from the share subdomain to the appropriate region, which is absent when you access one of the explore subdomains directly.

TL;DR: I've just tagged version v1.1.0 with the new base URL, which I believe may fix this issue for non-USA accounts. Please update using HACS and let me know if that works!

Figure-itout commented 6 months ago

That works for me! I am able to add the inreach of my friend. And the information is also correct.

miggland commented 6 months ago

Works now, thanks!