gophertunnel icon indicating copy to clipboard operation
gophertunnel copied to clipboard

Listener does not reserve port

Open AsherMaximum opened this issue 3 years ago • 2 comments

When setting the listener to 19132, it seems not to be reserving the port to prevent other apps from using it.

The BDS software will grab port 19132, regardless of the port you set, if that port is not in use. When I start a listener on port 19132, and then start a BDS server on some other port, the BDS server successfully grabs port 19132 as well, which causes a connection error when clients try to connect Wow, this server is popular. Check back later to see if slots open up.

I'm not sure if this is a BDS issue, or a Gophertunnel issue.
Or if I'm just not doing something I should be when I create the listener. I'm basically using the one from the example though:

	p := minecraft.NewStatusProvider(config.Connection.MOTD)

	var resourcePacks []*resource.Pack
	var pack *resource.Pack

	files, err := ioutil.ReadDir("resource_packs")
	if err != nil {
		fmt.Printf("Error reading resource_packs directory.")
	}
	fmt.Printf("Resource Packs found:\n")
	for _, file := range files {
		fmt.Println(file.Name(), file.IsDir())
		pack, _ = resource.Compile("resource_packs/"+file.Name())
		resourcePacks = append(resourcePacks, pack)
	}

	listener, err := minecraft.ListenConfig{
		StatusProvider: p,
		AuthenticationDisabled: false,
		MaximumPlayers: config.Connection.MaxPlayers,
		TexturePacksRequired: false,
		ResourcePacks: resourcePacks,
	}.Listen("raknet", config.Connection.Address+":"+fmt.Sprintf("%v",config.Connection.Port))
	if err != nil {
		panic(err)
	}
	defer listener.Close()
	for {
		c, err := listener.Accept()
		if err != nil {
			panic(err)
		}
		go handleConn(c.(*minecraft.Conn), listener, config, discordClient)
		fmt.Printf("Connection Handled\n")
	}

AsherMaximum avatar Jan 16 '22 17:01 AsherMaximum

Pretty sure this is more or less a problem with Go that we might not be able to do anything about other than report it on their issue tracker, a simple workaround would be to just..not run them on the same port

T14Raptor avatar Jan 22 '22 19:01 T14Raptor

yeah, problem is to get xBox/Switch players on, you need to run the server on 19132. My workaround for now is to start a dummy BDS server before starting my actual servers, and then shut down the dummy server after starting all the BDS servers and gophertunnel

AsherMaximum avatar Jan 24 '22 06:01 AsherMaximum

Unfortunately this is not something we can fix as it is a problem with how Go listens on ports. Going to close this issue.

Sandertv avatar Sep 05 '22 16:09 Sandertv