node-wifi icon indicating copy to clipboard operation
node-wifi copied to clipboard

wifi.connect error is undefined when password is incorrect.

Open kaleem68 opened this issue 4 years ago • 2 comments

Expected Behavior

wifi.connect should always return a proper error message when the ssid is correct & password is incorrect but it returns the 'undefined'

Current Behavior

sometimes wifi.connect returns error: Error: Command failed: netsh wlan add profile filename="nodeWifiConnect.xml" when the ssid is correct & password is incorrect, but most of the time error is undefined when ssid is correct and password is incorrect.

Code

   exports.conenect_to_wifi = function(req,res){
    var ssid_para = req.params.Ssid;
    var password_para = req.body.Password;
    wifi.init({
      iface: null 
    });
    wifi.connect({ ssid: ssid_para, password: password_para }, error => {
  
      console.log("error is ",error);
  
      if (error) {
        console.log("failed to connect with wifi");
        console.log(error);
      }
      else { 
      console.log("Wifi connected");
      console.log("Connected");
      }
    });
    res.json({message: "password receive successfully"});
  }

Your Environment

  • OS: Windows, Mac

kaleem68 avatar Jan 26 '21 15:01 kaleem68

Same problem here. The connection would fail at first but without return error messages, and the connection will fallback to the original WiFi since it has the correct profile stored. (Mac)

sundong212 avatar Feb 23 '21 06:02 sundong212

Same problem here

quanc avatar Apr 06 '21 06:04 quanc