Create_match request gets cancelled (Godot)

Godot debug:

=== Nakama : DEBUG === Sending async request: MatchCreate<>
=== Nakama : DEBUG === Cancelling response: 1
=== Nakama : DEBUG === Resuming response: 1: NakamaException(StatusCode={-1}, Message=‘{Request cancelled.}’, GrpcStatusCode={-1})
An error occured: NakamaException(StatusCode={-1}, Message=‘{Request cancelled.}’, GrpcStatusCode={-1})

Code:

var created_match : NakamaRTAPI.Match = yield(socket.create_match_async(), “completed”)
if created_match.is_exception():
print(“An error occured: %s” % created_match)
return
print(“New match with id %s.”, created_match.match_id)

How to fix it?

@darvin7531 can you run the server with DEBUG level logs enabled (use --logger.level DEBUG) and let me know if you see any specific error messages in the logs related to the logic to create the multiplayer match?

I have same issue :confused: Does it have any solutions? :pleading_face:

Debug log

=== Nakama : DEBUG === Sending async request: ChannelJoin<persistence=true, hidden=false, target=9fb805aa-c025-4478-876f-f8ee6678ca53, type=3>
=== Nakama : DEBUG === Cancelling request: 1
=== Nakama : DEBUG === Resuming request: 1: NakamaException(StatusCode={-1}, Message=‘{Request cancelled.}’, GrpcStatusCode={-1})

Also Godot sends warn:

E 0:00:05:0968 NakamaSocketAdapter.gd:55 @ send(): Condition “ready_state != STATE_OPEN” is true. Returning: FAILED
<Исходный код C++>modules/websocket/wsl_peer.cpp:700 @ _send()
<Трассировка стека>NakamaSocketAdapter.gd:55 @ send()
NakamaSocket.gd:295 @ _send_async()
NakamaSocket.gd:360 @ join_chat_async()

Code fragment:

func send(p_buffer : PackedByteArray, p_reliable : bool = true) → int:
_ws.get_close_reason()
return _ws.send(p_buffer, WebSocketPeer.WRITE_MODE_TEXT)

@Delalex I’m not very familiar with Godot but from the logs I suspect the socket is being closed prematurely before the request is completed.

Oh, yes. Output of print(socket.is_connected_to_host()) returns false. I would be very grateful if you could help me

Perhaps our Godot Guide might be useful to you.

1 Like

Did you find a solution to this? I am facing the exact same issue after the app is kept in background for some time

1 Like

@Ayush-Agarwal123 I’m not very familiar with mobile development but, as far as I know, if an app is put in the background the sockets may be closed by the OS, your app needs to be able to handle this scenario.