Apollon77/meross-cloud

Fix for too many tokens have been issued (error 1031)

Closed this issue · 7 comments

Is your feature request related to a problem? Please describe.

While developing using your library, I ended up getting into an bad state:

connect error: Error: 1301 (Too many tokens have been issued) - Beyond Login Limit

Describe the solution you'd like
A clear and concise description of what you want to happen.

Please handle cleanup/close/logout/return token on exit!

process.on('exit', () => {

})

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

I'm stuck! I had to email support@meross.com. Haven't heard back yet.

Additional context
Add any other context or screenshots about the feature request here.

I'm using forever to restart my program when code files have changed. It does a SIGKILL, which you cannot catch. I think you might want to warn everyone in the README to be careful and not use anything that does SIGKILL or you end up with too many tokens issued without a logout.

It's really bad! I can't even log into the Meross app on my phone.

If you know of a workaround please let me know.

Can the local http and/or MQTT (I have a broker already set up) be used without getting a login token from Meross cloud?

Please provide an example how to do this :)

Maybe a safe way to do authentication is to save the token in a file. Upon startup, read the token and if it's no longer valid, then go get another one?

Easy solution :-) Use logout() ... https://github.com/Apollon77/meross-cloud/blob/master/index.js#L226

ideally you should store the session and reuse it - or if you end your process call logout to clear the login token

I know about logout. The problem is I’m using forever to restart the program when the source files change and it sends a SIGKILL, which doesn’t allow the program to cleanup before exit.

Every time I saved in my editor, it ended up requesting a new token!

Thats bad :-( But I have no solution for you.. You need to wait for Meross to clear it and then you can start fresh again and try to prevent it fropm happenning again that weay

I was thinking that storing and reusing the session toke is ideally suited for this library to do… make sense?

The library currently do not have any kind of storage and I would not start introducing one "just for that", but yes maybe a note in Readme if it is not clear enough would make sense