Couldn't create an ENet host
Asked Answered
C

1

0

Hello everyone! In my game, when I try to create an ENet server, I get this error:

E 0:00:24:0728   world.gd:45 @ _on_host_button_pressed(): Couldn't create an ENet host.
  <C++ Error>    Condition "!host" is true. Returning: ERR_CANT_CREATE
  <C++ Source>   modules/enet/enet_connection.cpp:318 @ _create()
  <Stack Trace>  world.gd:45 @ _on_host_button_pressed()
                 holepunch_node.gd:132 @ _handle_go_message()
                 holepunch_node.gd:80 @ _process()

I'm using Godot 4.0-stable on Arch Linux and this is the relevant function:

func _on_host_button_pressed():
	main_menu.hide()
	hud.show()
	
	hole_puncher.rendevouz_address = RV_ADDRESS
	hole_puncher.rendevouz_port = RV_PORT
	
	add_child(hole_puncher)
	
	hole_puncher.start_traversal(address_entry.text, true, OS.get_unique_id())
	
	var result = await hole_puncher.hole_punched
	print("punch")
	var port = result[0]
	print(port)
	
	multiplayer.multiplayer_peer = null
	
	print(enet_peer.create_server(port, 1))
	multiplayer.multiplayer_peer = enet_peer
	multiplayer.peer_connected.connect(add_player)
	multiplayer.peer_disconnected.connect(rm_player)
	
	add_player(multiplayer.get_unique_id())

In addition to this, the entirety of the code can be found on GitHub here

I don't believe it's an issue with what IPs and ports I am using, as the ports are randomly generated by my hole-punching server I believe and I have tried different ports for that server. Also, the IPs I am using currently are local, and I have tried running the two instances of the game on not only the same machine, but also on different machines so they have different IPs.

The game is a little FPS game using hole-punching and my Raspberry Pi as the server. When the error refers to "host", I believe it is referring to the player who created the game room, rather than the Raspberry Pi hole-punching server. I apologise for the lack of detail in my question, there is simply not much I can find about this issue. It is likely one of those strange issues with a simple fix I believe.

Contraindicate answered 14/3, 2023 at 0:29 Comment(0)
C
0

Still can't figure this out :/

Contraindicate answered 16/3, 2023 at 16:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.