heroiclabs / nakama-godot

Godot client for Nakama server written in GDScript.
Apache License 2.0
593 stars 69 forks source link

create_match_async() does not work unless i pass an empty string (issue only with HTTPS, HTTP runs fine) #213

Closed michel9092 closed 2 weeks ago

michel9092 commented 3 weeks ago

Hello, I have created some very basic Nakama client code, like login and create/join match. Everything worked great for HTTP. But with the same code, and over HTTPS, I cannot pass anything into the function create_match_async() except for an empty string.

Godot v4.2.2.stable.official[15073afe3]

When I pass an empty string:

var createdMatch = await socket.create_match_async("")
=== Nakama : DEBUG === Sending async request: MatchCreate<name=<null>>
=== Nakama : DEBUG === Resuming request: 1: { "cid": "1", "match": { "match_id": "d201cec7-0014-43ec-a224-810d9a164249.", "size": 1, "self": { "user_id": "df0a2f3a-c953-4311-b368-57e71ac8c673", "session_id": "4c09b386-5f2d-11ef-8816-7106fdcb5b46", "username": "SEihNJgOWE" } } }
Successfully created match

When I pass a non empty string (socket immediately closes):

var createdMatch = await socket.create_match_async("test")
=== Nakama : DEBUG === Sending async request: MatchCreate<name=test>
socket closed
=== Nakama : DEBUG === Cancelling request: 1
=== Nakama : DEBUG === Resuming request: 1: NakamaException(StatusCode={-1}, Message='{Request cancelled.}', GrpcStatusCode={-1})
failed to create match

I traced it back to why the socket is being closed immediately, and it seems to be coming from the NakamaSocketAdapter.gd, specifically line 57:

    if _ws.get_ready_state() != WebSocketPeer.STATE_CLOSED:
        _ws.poll()

Also note that anything that does not require me to pass a string, such as automatic matchmaking, works just fine over HTTPS. Thank you for any help/direction.

Edit: I am not very knowledgeable in this, if your solution require that I add logging code, etc., kindly explain in detail.

Edit 2: I get this message in the server for empty string:

nakama-1       | {"level":"debug","ts":"2024-08-26T17:00:55.311Z","caller":"server/pipeline.go:65","msg":"Received *rtapi.Envelope_MatchCreate message","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"c047235d-63cc-11ef-bf4a-7106fdcb5b46","cid":"1","message":{"MatchCreate":{}}}
nakama-1       | {"level":"debug","ts":"2024-08-26T17:00:55.311Z","caller":"server/session_ws.go:395","msg":"Sending *rtapi.Envelope_Match message","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"c047235d-63cc-11ef-bf4a-7106fdcb5b46","envelope":"cid:\"1\"  match:{match_id:\"d6723e1e-d004-4a45-b0ba-fea38c17a885.\"  size:1  self:{user_id:\"c068eddb-b006-4df6-b281-29529a1bfe77\"  session_id:\"c047235d-63cc-11ef-bf4a-7106fdcb5b46\"  username:\"YVHLsdCrmA\"}}"}
nakama-1       | {"level":"debug","ts":"2024-08-26T17:00:55.312Z","caller":"server/tracker.go:834","msg":"Processing presence event","joins":1,"leaves":0}

And this message for match named "test":

nakama-1       | {"level":"warn","ts":"2024-08-26T16:55:03.899Z","caller":"server/session_ws.go:239","msg":"Received malformed payload","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"e5b7b430-63cb-11ef-bf4a-7106fdcb5b46","data":"eyJjaWQiOiIxIiwibWF0Y2hfY3JlYXRlIjp7Im5hbWUiOiJ0ZXN0In19"}
nakama-1       | {"level":"info","ts":"2024-08-26T16:55:03.902Z","caller":"server/session_ws.go:438","msg":"Cleaning up closed client connection","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"e5b7b430-63cb-11ef-bf4a-7106fdcb5b46"}
nakama-1       | {"level":"info","ts":"2024-08-26T16:55:03.902Z","caller":"server/session_ws.go:446","msg":"Cleaned up closed connection matchmaker","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"e5b7b430-63cb-11ef-bf4a-7106fdcb5b46"}
nakama-1       | {"level":"info","ts":"2024-08-26T16:55:03.902Z","caller":"server/session_ws.go:450","msg":"Cleaned up closed connection tracker","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"e5b7b430-63cb-11ef-bf4a-7106fdcb5b46"}
nakama-1       | {"level":"info","ts":"2024-08-26T16:55:03.902Z","caller":"server/session_ws.go:454","msg":"Cleaned up closed connection status registry","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"e5b7b430-63cb-11ef-bf4a-7106fdcb5b46"}
nakama-1       | {"level":"info","ts":"2024-08-26T16:55:03.902Z","caller":"server/session_ws.go:458","msg":"Cleaned up closed connection session registry","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"e5b7b430-63cb-11ef-bf4a-7106fdcb5b46"}
nakama-1       | {"level":"info","ts":"2024-08-26T16:55:03.902Z","caller":"server/session_ws.go:475","msg":"Closed client connection","uid":"c068eddb-b006-4df6-b281-29529a1bfe77","sid":"e5b7b430-63cb-11ef-bf4a-7106fdcb5b46"}
linear[bot] commented 3 weeks ago

SDK-845 create_match_async() does not work unless i pass an empty string (issue only with HTTPS, HTTP runs fine)

michel9092 commented 2 weeks ago

Hello, this was caused by Nakama v3.4.0, since I copied the docker-compose file from an old tutorial. Now Nakama v3.22.0 works perfectly fine on HTTPS! Thank you!