mujx / hakatime

Wakatime server implementation & analytics dashboard
https://hakatime.mtx-dev.xyz
The Unlicense
611 stars 45 forks source link

import data from wakatime timeout #43

Closed WankkoRee closed 2 years ago

WankkoRee commented 2 years ago

I am in Hong Kong. If i use api.wakatime.com, it will time out. But if I use wakatime.com, then everything works fine.

image

So can there be an option in docker-compose-deploy.yml for setting importing from which domain? Just like HAKA_WAKATIME_HOST: "wakatime.com"

mujx commented 2 years ago

Are you sure the problem is your location and not the amount of data you're expecting? Maybe the server is slow to respond and a second try will most likely fetch your data.

You can check that both wakatime.com & api.wakatime.com are in California, USA so the latency should be the same. Or is api.wakatime.com blocked in Hong Kong?

WankkoRee commented 2 years ago

Look at the screenshot I uploaded earlier. I did not set user credentials such as cookies and tokens. I just send an anonymous request. But the response time of the two domains is quite different.

mujx commented 2 years ago

You're right. It seems like the api.wakatime.com is only redirecting to wakatime.com/api on HTTP . This will work curl http://api.wakatime.com/v1/users/current/heartbeats, but it returns HTML instead of JSON. Removing the /api path with HTTPS likecurl https://api.wakatime.com/v1/users/current/heartbeats also works but still no JSON.

I'll provide a variable to control this endpoint. Thanks for the suggestion.

mujx commented 2 years ago

@WankkoRee I pushed a quick fix that uses the correct endpoint (wakatime.com). In the future this will be configurable.

WankkoRee commented 2 years ago

Thank you for your timely fix. I tried to import again and everything was working.