question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows: getCurrentConnections returns null when multiple interfaces exist

See original GitHub issue

When there are multiple wifi interfaces exist in Windows environment and if the first one is disconnected, the getCurrentConnections() returns null.

Expected Behavior

The getCurrentConnections() should return connected connections from any interfaces

Current Behavior

When there are multiple wifi interfaces exist in Windows environment and if the first one is disconnected, the getCurrentConnections() returns null.

Affected features

  • [Y] node API
  • cli

Possible Solution

I have confirmed working after modified the windows-current-connections.js by following:

function parseShowInterfaces(stdout) {
...
    for (var j = 0; j < fields.length; j++) {
      var line = lines[i + j];
//=====  MY CHANGE START
 // tmpConnection[fields[j]] = line.match(/.*: (.*)/)[1];
      const lineMatch = line.match(/.*: (.*)/);
      if (lineMatch == null) { 
        // bad line, skip current interface and move to next one
        i += j + 1;
        j = -1;
      } else {
        tmpConnection[fields[j]] = lineMatch[1];
      }
//=====  MY CHANGE END
...
}

Steps to Reproduce (for bugs)

  1. Prepare environment with two wifi interfaces
  2. Only connect wifi from second wifi interfaces. I.e. second means whatever it appears in second from ‘netsh wlan show interfaces’
  3. Run wifi-node.getCurrentConnections()
  4. Check the output.

Context

Your Environment

  • OS:
  • node-wifi version
  • wifi card:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
friedrithcommented, Dec 30, 2021

Ok I will try to propose a fix

0reactions
friedrithcommented, Jan 18, 2022

I am glad you found a workaround. Unfortunately, windows use async commands so you don’t know exactly when the job will be finished.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · friedrith/node-wifi
[Bug]: Wrong data returns for getCurrentConnections on windows 11 ... Windows: getCurrentConnections returns null when multiple interfaces exist.
Read more >
About WinHTTP API behavior with multiple network interfaces
If multiple network interfaces (NICs) exist, the above API is supposed to automatically select the network interface to use.
Read more >
Internet connection sharing null Windows 10
Context: I have bad wifi in my room and hence tried to enable internet connection sharing but got a null message, " An...
Read more >
Unable to connect to internet using multiple interfaces.
Started troubleshooting after booting up my PC, ping 127.0.0.1 returns with "unable to contact IP driver. General failure" A Tracert for ...
Read more >
Dual-STA query and configuration - Win32 apps
There are two types of interfaces associated with adapters that support dual ... dwResult); WlanCloseHandle(hClient, NULL); return dwResult; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found