Giter Club home page Giter Club logo

Comments (6)

lugehorsam avatar lugehorsam commented on June 23, 2024

Hey @Coxcopi could you share a snippet of your code and where the exception is raised?

from nakama-godot.

Coxcopi avatar Coxcopi commented on June 23, 2024

@lugehorsam sure, this is what the code for setting up client and socket looks like:

func setup() -> void:
	_client = _connect_to_server()
	_socket = _create_socket(_client)

func _connect_to_server() -> NakamaClient:
	var client : NakamaClient = Nakama.create_client(
		"defaultkey",
		"127.0.0.1",
		7350,
		"http",
		3,
		NakamaLogger.LOG_LEVEL.INFO
	)
	client.timeout = CLIENT_REQUEST_TIMEOUT
	return client

func _create_socket(client : NakamaClient) -> NakamaSocket:
	if (!client):
		return null
	return Nakama.create_socket_from(client)

And here's when I tried using methods from the socket:

Joining Matchmaker:

func join_matchmaker(query : String = "*", min_count : int = 2, max_count : int = 8) -> void:
	var socket : NakamaSocket = NetServerConnection.get_socket()
	if (!socket):
		return
	var ticket_response : NakamaRTAPI.MatchmakerTicket = await socket.add_matchmaker_async(
		query, 
		min_count,
		max_count
	)
	if (ticket_response.is_exception()):
		Logger.log_error("NetMatchManager: join_matchmaker() error: %s" % ticket_response)
	matchmaker_ticket = ticket_response.ticket

Following friends status:

func follow_friends_status() -> void:
	var socket : NakamaSocket = NetServerConnection.get_socket()
	if (!socket):
		return
	var friends_result : Array[NakamaAPI.ApiUser] = await get_friends(FriendshipState.MUTUAL, 20)
	var friend_ids : Array[String] = []
	for user in friends_result:
		if (!user.online):
			continue
		friend_ids.append(user.id)
	var result : NakamaAsyncResult = await socket.follow_users_async(friend_ids, [])
	if (result.is_exception()):
		Logger.log_error("PresenceManager: follow_friends_status() error: %s" % result.get_exception().message)

Both of these resulted in the error I mentioned, and I can't seem to figure out where the problem is coming from.

from nakama-godot.

Coxcopi avatar Coxcopi commented on June 23, 2024

Not sure if that information is also relevant but I'm running the latest nakama docker image locally on a Windows 10 machine using Docker Desktop.

from nakama-godot.

dsnopek avatar dsnopek commented on June 23, 2024

The Request cancelled. cancelled message comes from the client when there's an error sending data on the WebSocket.

Is there any information in the Nakama logs? In particular, do you see the WebSocket connection coming through?

Also, your code doesn't show authenticating before creating the socket. I'm assuming you're doing that and simply not showing it, but double checking just in case. :-)

from nakama-godot.

Coxcopi avatar Coxcopi commented on June 23, 2024

@dsnopek there actually is an error thrown in Godot (which I unfortunately didn't really notice before, otherwise I would've included it in the original issue of course), which seems to happen in the NakamaSocketAdapter.send() method:

E 0:00:12:0795   NakamaSocketAdapter.gd:54 @ send(): Condition "ready_state != STATE_OPEN" is true. Returning: FAILED

Looks like something's wrong with the WebSocket, though I'm not sure if it's an issue with the Nakama addon code or if I'm just missing something.

Also you're absolutely right, I left out the authentication code as I don't think it has to do with the problem, and I made sure that the authentication was working as intended.

Full stacktrace:

  <C++ Source>   modules/websocket/wsl_peer.cpp:703 @ _send()
  <Stack Trace>  NakamaSocketAdapter.gd:54 @ send()
                 NakamaSocket.gd:295 @ _send_async()
                 NakamaSocket.gd:351 @ follow_users_async()
                 net_account_manager.gd:237 @ follow_friends_status()
                 net_account_manager.gd:1347839312 @ get_friends()
                 NakamaClient.gd:1347838512 @ list_friends_async()
                 NakamaAPI.gd:1347838192 @ list_friends_async()
                 NakamaHTTPAdapter.gd:1347836752 @ send_async()
                 NakamaHTTPAdapter.gd:1347841872 @ _send_async()
                 NakamaHTTPAdapter.gd:1347842832 @ make_request()

from nakama-godot.

Coxcopi avatar Coxcopi commented on June 23, 2024

It turns out I'm incredibly stupid. I spent hours digging through the addon code trying to find errors when I just now realized that I never actually called _socket.connect(), which of course has my methods fail simply because the socket obviously can't send anything without a connection.
I apologize for keeping this issue open for so long (and making it in the first place), next time I'll check my own code first 😄

from nakama-godot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.