vladfaust / unity-wakatime

WakaTime plugin for Unity ⏱
MIT License
121 stars 27 forks source link

Handle HTTP status codes #13

Open Hermesiss opened 5 years ago

Hermesiss commented 5 years ago

I have an editor component that actively updates while selected, causing very often heartbeats. After a few seconds System.ArgumentException: JSON parse error: Invalid value. starts to appear. Server responses with

<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx</center>
</body>
</html>

Looks like we need to check for response type and react to errors respectively. Like with temporal timeout for 405 and consider other reactions

Alternatively, in case of 405, we can increase Plugin.HEARTBEAT_COOLDOWN

Can implement after understanding Wakatime server responses or hints from @wakatime members

vladfaust commented 5 years ago

Nice catch. This plugin doesn't currently handle any network errors for sure. It would be good to have a list of known error statuses WakaTime can return. /cc @alanhamlett

Hermesiss commented 5 years ago

There's no 405 reference at dev section

alanhamlett commented 5 years ago

That was a bug in our server's nginx config, where 429 serving a custom static error page turns into 405 because Nginx doesn't allow custom static error pages for POST requests. It's fixed now and the correct 429 response code is returned.