mark2b/wpa-connect

Error - "address_not_allocated"

Closed this issue · 4 comments

Hello.
My code.

package main

import (
	"fmt"
	"time"

	wifi "github.com/mark2b/wpa-connect"
)

func main() {
	ssid := "My_name_wifi"
	password := "My_password_wifi"
	if conn, err := wifi.ConnectManager.Connect(ssid, password, time.Second*60); err == nil {
		fmt.Println("Connected", conn.NetInterface, conn.SSID, conn.IP4.String(), conn.IP6.String())
		// fmt.Println("Connected", conn)
	} else {
		fmt.Println("Err connect: ", err)
	}
}

An error appears - "address_not_allocated".
Wifi is working properly. The password is correct.
Can you tell me what the problem may be?

I understand that the problem is related to the code -

func (self *connectContext) hasIP() bool {
	return self.ip4 != nil && self.ip6 != nil
}

Hello, It looks like DHCP didn't allocate IP address (v4 & v6) for some reason.
There is a loop that waits for IP allocation during timeout you provided.

Hello, It looks like DHCP didn't allocate IP address (v4 & v6) for some reason.
There is a loop that waits for IP allocation during timeout you provided.

I only run "ifconfig" with root privileges. Could this be the reason for the error?

You should run wpa-connect with root / sudo

You should run wpa-connect with root / sudo

Thank you for your help!