Closed dozgunyal closed 3 years ago
Hey @dozgunyal are you restarting the server at any point during the reproduction of your issue?
If you get the chance, also let me know what issue you hit when running the tests.
hi, nope the server is not being restarted. I believe the problem is the bearerToken is not being deleted in authenticate functions: https://github.com/dozgunyal/nakama-js/blob/master/packages/nakama-js/client.ts#L505
and it is causing 401 during reconnect because the token is invalid now. https://github.com/dozgunyal/nakama-js/blob/master/packages/nakama-js/api.gen.ts#L651
I was going to add
this.configuration.bearerToken = undefined;
to every authenticate function.
About the tests:
I get: SyntaxError: Cannot use import statement outside a module
errors
and lot's of other stuff. I didn't spend much time on them. it may be node version or smth.
While re-authentication of a device, server always returns 401.
I believe this is because of an old bearerToken which is not cleared during the server authentication request.
I will try to open a pull request. : failed, because I couldn't manage to run the tests. I will not open a pull request.
to reproduce: Create a short session using client.authenticateDevice(id); wait until it expires. try to create another session using client.authenticateDevice(id);
Error message:
{"type":"default","status":401,"ok":false,"statusText":"","headers":{"map":{"content-encoding":"gzip","cache-control":"no-store, no-cache, must-revalidate","content-length":"66","content-type":"application/json","vary":"Accept-Encoding","date":"Mon, 24 May 2021 22:40:02 GMT"}},"url":"http://127.0.0.1:7350/v2/account/authenticate/device?","bodyUsed":false,"_bodyInit":{"_data":{"size":42,"offset":0,"blobId":"95393CD0-52C6-41B2-A924-19B810B1FA20","type":"application/json","name":"device","__collector":{}}},"_bodyBlob":{"_data":{"size":42,"offset":0,"blobId":"95393CD0-52C6-41B2-A924-19B810B1FA20","type":"application/json","name":"device","__collector":{}}}}