jackpal/go-nat-pmp

GetExternalAddress not working

ethsmith opened this issue · 1 comments

Hello,
I am using your library and the function GetExternalAddress() is not returning an error but it isn't returning a proper result either, it just gets stuck at that part of my program.

	gatewayIP, err := gateway.DiscoverGateway()
	if err != nil {
		log.Fatalln("Can't discover gateway: " + err.Error())
	} else {
		client := natpmp.NewClient(gatewayIP)
		fmt.Println("Created a new client!")
		address, err := client.GetExternalAddress()
		if err != nil {
			log.Fatalln("Can't get external address: " + err.Error())
		} 
	}

It sounds like your gateway does not support NAT-PNP. In that case it will take about 128 seconds for GetExternalAddress to fail, due to exponential backoff as specified by the protocol. I'll add that to the docs.