pokusew / nfc-pcsc

Easy reading and writing NFC tags and cards in Node.js
MIT License
535 stars 132 forks source link

new NFC() hangs on windows 10 #84

Open fatmatto opened 5 years ago

fatmatto commented 5 years ago

Hello,

I tried the example on the README file on a windows 10 tablet and it hangs on the line:

const nfc = new NFC(); 

Inspecting the code in the node_modules/nfc-pcsc/dist directory I found out that it blocks at the line following line in dist/NFC.js

this.pcsc = (0, _pcsclite.default)()

Which in turns blocks at the line

const p = new PCSCLite()

in @pokusew/pcsclite/lib/pcsclite.js

Is there anything that is required to make the library work on Windows 10?

The system configuration is

node v10.15.3
npm 6.4.1
Windows 10 Enterprise 
pokusew commented 5 years ago

Hi @fatmatto, it is known issue on Windows that can occur in some situations. See https://github.com/pokusew/node-pcsclite/issues/21.

The example was run on a Windows 10 (Pro) machine that had never had a smart card device plugged in to it. The example seems to run fine on Win 10 machines that have seen a smart card device.

Smart Card Service on Windows is not running by default and is only started when a NFC reader is connected (I tried to change this behavior, but it does not seem to be possible). This had been causing pcsclite (nfc-pcsc) to crash. I (my friend on Windows, I use macOS) did some fixes (https://github.com/pokusew/node-pcsclite/commit/9f871e90966d852e440ff62025ca4c70f72c8667) that seemed to fix the issue. Apparently, now in some configurations (e.g. on a machine that had never had a smart card device plugged in to it), the issue you describing occurs.

There is already a PR https://github.com/pokusew/node-pcsclite/pull/22 that is addressing this issue. Unfortunately, I haven't got enough time yet to examine it and eventually merge the fix.

Hope it helps. 🙂


As soon as I get some time (hopefully in a month or so), I try to look into this and merge the PR.

fatmatto commented 5 years ago

Hi @pokusew Thank you for the reply, since i already used the NFC reader on that device (with a Windows native app) I assumed it counted as a smart card device previously plugged in :)

While you handle the PR i'll take a look at it and try with a fork of the repo.

Thank you for the repo and for your time :)

cloudhx commented 4 years ago

Hello,

I have the same issue with windows 10, I tried to manually start the Smart Card service, but it didn't help.

Is this something that can be fixed?

Thank you very much!

cloudhx commented 3 years ago

Hi,

Just tested the package on Windows 10 and it works well.

Thank you.

kumarmboxuk commented 3 years ago

Can you explain how did you fix this issue please? :)

ghost commented 3 years ago

I am running into the same issue and it's unclear to me how to fix this.

[EDIT]

I have made sure I am running the latest version of this package. Tried with Node 14, Node 16 and Node 13 and all have the same issue. The program just hangs there forever.

@cloudhx @kumarmboxuk how did you fix this?

cloudhx commented 3 years ago

@Fossil01 @kumarmboxuk I'm using ACR122 reader and as I remembered you need to install the driver for it on Windows.

esskar commented 7 months ago

The hanging also happens, when trying to run new NFC() while conneting via remote desktop

adlanarifzr commented 7 months ago

The hanging also happens, when trying to run new NFC() while conneting via remote desktop

You need to make sure the windows device connected to the reader.