Hi, I got the server running with docker-compose and set socket.token_expiry_sec
to 604800 (one week). The rest of the settings are the defaults (obtained via the “export” button in the web interface).
I then followed the Godot tutorial and added a few small modifications, but it seems like the session expires right after creation, causing my code to always create a new one using authenticate_device_async
.
Did I do anything wrong or is this a bug?
Here is my code (which is autoloaded as a singleton) and the output of running said code. I’ve also added the contents of store.ini
just in case:
Code
# GameClient.gd
extends Node
const STORE_FILE = "res://store.ini"
const STORE_SECTION = "nakama"
const STORE_KEY = "session"
var session: NakamaSession = null
onready var client = Nakama.create_client(
"defaultkey",
"192.168.99.100",
7350,
"http"
)
func _ready() -> void:
var cfg := ConfigFile.new()
cfg.load(STORE_FILE)
var token = cfg.get_value(STORE_SECTION, STORE_KEY, "")
if token:
var restored_session = NakamaClient.restore_session(token)
if restored_session.valid and not restored_session.expired:
session = restored_session
print_debug('Authenticated with previously stored session')
return
var deviceid := OS.get_unique_id()
session = yield(client.authenticate_device_async(deviceid), "completed")
# The following statement seems to always be true:
print_debug("Is new session expired: ", session.expired)
if session.is_exception():
print_debug("Authentication error: ", session.get_exception().message)
return
cfg.set_value(STORE_SECTION, STORE_KEY, session.token)
cfg.save(STORE_FILE)
print_debug('Authenticated with newly created session')
Output
Is new session expired: True
At: res://GameClient.gd:30:_ready()
Authenticated with newly created session
At: res://GameClient.gd:38:_ready()
Contents of store.ini
[nakama]
; This is rewritten every time the code runs
session="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIyMjk2Nzk5MC1iMGY5LTQ4ZDQtODU5MC00MGViYTFkMjhjM2IiLCJ1c24iOiJUaU5nYm9xa1lLIiwiZXhwIjoxNTgzOTIxMjE3fQ.Ast0ItbD7BRJ5Y_-MJkCJ84tqwqp6QXVCyy_7Hjwzt8"