ocilo / skype-http

Unofficial Skype API for Node.js via HTTP
https://ocilo.github.io/skype-http
MIT License
51 stars 24 forks source link

connect through state very temperamental #39

Open mitchcapper opened 7 years ago

mitchcapper commented 7 years ago

For example calling after awaiting the connect:

fs.writeFileSync("state.json", JSON.stringify(await api.getState()));

then for when connecting doing:

let state = fs.readFileSync("state.json", 'utf8');
let api = await skypeHttp.connect({ verbose: true, state: JSON.parse(state) });

will periodically not connect properly, and will not throw an error either. I have added inside the normal connect T/C: await api.setStatus("Online"); as if it doesn't connect right this command will fail.

skypeHttp.connect state resuming should always throw an error if resuming from state does not work (even if we have to make a no-op call after loading state to the skype service to make sure we are all good).

demurgos commented 7 years ago

You are right, restoring the state should use a no-op (but maybe not setStatus) to ensure that we are properly logged in. I was using it while developing the feature to restore from a saved state but it got lost before the merge into master. The connect function could do a getConversations or getContacts at the end. The first one checks for the registration token, the second one for the Skype token.

mitchcapper commented 7 years ago

Whatever the smallest request the better (from a speed/BW point of view). We also should add the reconnect option as discussed (so users do not need to re-create the instance to reconnect).

mitchcapper commented 6 years ago

I am going to update this and say while the current error and complete re-create works 95% of the time, I have found there is 5% of the time where it will not be getting proper events and not throwing an error leading to missed events. I have yet to find a solution to this.

demurgos commented 6 years ago

Thank you for working on this issue.

demurgos commented 6 years ago

Restoring the state seems to work pretty fine for the Skype token but fail with the registration token if it stopped for more than a few minutes. We may need to issue a new registration token (endpoint) to fix this.