davidkroell / bodycomposition

Bodycomposition is a program to manage your body measurements and composition stored in Garmin Connect from your beloved commandline.
Apache License 2.0
33 stars 3 forks source link

Problem with cobra library ? #6

Closed RobertWojtowicz closed 4 years ago

RobertWojtowicz commented 4 years ago

panic: social profile not found in HTML

goroutine 1 [running]: github.com/davidkroell/bodycomposition.BodyComposition.uploadFitFile(0x0, 0xed6e53c22, 0xc9f1c0, 0x404cc66666666666, 0x402a8a3d70a3d70a, 0x404dc00000000000, 0x4012000000000000, 0x40548f5c28f5c28f, 0x4013eb851eb851ec, 0x4018000000000000, ...) /home/davidk/go/src/github.com/davidkroell/bodycomposition/main.go:78 +0x1c4 github.com/davidkroell/bodycomposition.BodyComposition.UploadWeight(0x0, 0xed6e53c22, 0xc9f1c0, 0x404cc66666666666, 0x402a8a3d70a3d70a, 0x404dc00000000000, 0x4012000000000000, 0x40548f5c28f5c28f, 0x4013eb851eb851ec, 0x4018000000000000, ...) /home/davidk/go/src/github.com/davidkroell/bodycomposition/main.go:97 +0x21d github.com/davidkroell/bodycomposition/cmd.glob..func1(0xc12e80, 0xc000084b00, 0x0, 0x16) /home/davidk/go/src/github.com/davidkroell/bodycomposition/cmd/upload.go:47 +0x4a6 github.com/spf13/cobra.(Command).execute(0xc12e80, 0xc0000849a0, 0x16, 0x16, 0xc12e80, 0xc0000849a0) /home/davidk/go/src/github.com/spf13/cobra/command.go:845 +0x2ae github.com/spf13/cobra.(Command).ExecuteC(0xc12be0, 0xc000080100, 0xc000080100, 0xc000080100) /home/davidk/go/src/github.com/spf13/cobra/command.go:946 +0x318 github.com/spf13/cobra.(*Command).Execute(...) /home/davidk/go/src/github.com/spf13/cobra/command.go:886 github.com/davidkroell/bodycomposition/cmd.Execute() /home/davidk/go/src/github.com/davidkroell/bodycomposition/cmd/root.go:24 +0x32 main.main() /home/davidk/go/src/github.com/davidkroell/bodycomposition/cmd/bodycomposition/main.go:8 +0x20

RobertWojtowicz commented 4 years ago

Looks like Garmin is having performance issues? Once it is possible to load the data, once not :( It looks like Garmin is temporarily banning the number of sessions and public IP addresses ?

davidkroell commented 4 years ago

I never encountered a similar error, but this is not officially supportet, so this is maybe the fault. Do you have another thought on this?

RobertWojtowicz commented 4 years ago

I did the tests again, unfortunately now I have the same errors. Regardless of whether I run it through my script or manually from the command line. I can send it for a few tries.

Maybe it would be good to compile a version with all dependent libraries ?, just do not know how to do it.

RobertWojtowicz commented 4 years ago

This looks like a communication problem with additional libraries ("github.com/abrander/garmin-connect", "github.com/tormoder/fit", "github.com/davidkroell/bodycomposition", "golang.org/x/crypto/ssh/terminal "," github.com/spf13/cobra", "github.com/davidkroell/bodycomposition/cmd") or with Garmin Connect (throttling cloud?), because today I sent correctly after 4 attempt.

For example, the 7th time it was not possible to send another sample (3 next samples the same errors - from this topic), but this time Garmin temporarily banned me (Authentication failed).

I found a total of three types of failure messages:

  1. Garmin temporarily banned: ... uploading weight Authentication failed

  2. Problem with bodycomposition and dependent libraries ? ... uploading weight panic: social profile not found in HTML

  3. Problem with bodycomposition and dependent libraries ? ... uploading weight panic: forbidden

I am thinking with my colleague about the condition if the program displays only "... uploading weight" without any additional characters, we assume that the file has been sent correctly and is archived so as not to send it again. If there are additional information, do not archive, but retry sending in 1 minute (cron)

davidkroell commented 4 years ago

Hi, @RobertWojtowicz

I currently work on improving this CLI tool, since a dependent library got an awesome update (with API change). Furthermore I worked on this issue and asked the maintainer or the dependecy.

I also implemented a more convienient error handling and came to the point that maybe a parameter --max-tries or something would overcome this issue. Just try as long as it works 🤔

Regards, David

RobertWojtowicz commented 4 years ago

Currently I have created a workaround in a script and checked for errors: https://github.com/RobertWojtowicz/miscale2garmin/blob/master/import_mqtt.sh

davidkroell commented 4 years ago

Ok, this should no longer be necessary if the new version is released. I also want to add a non-zero exit status in case of error for better third-party integration

What do you think about such a parameter?

RobertWojtowicz commented 4 years ago

I don't fully understand, but it sounds good :)

Okay, I'm waiting for the new version, when it's ready, I will test it :)

RobertWojtowicz commented 4 years ago

Everything works fine, I have improved my scripts for the new version. I also checked -max-tries parameter, it works fine, but it's easy to get banned by Garmin :)