Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

botframework - node.js error message events.js:183 throw er; // Unhandled 'error' event

Playing around Microsoft's botframework, when I try to run the app.js file, which is the main file of the bot, the first time is fine, after I close the bot emulator, and all programs, and run the app.js again, this error message pops out

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3978
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at Server.setupListenHandle [as _listen2] (net.js:1351:14)
    at listenInCluster (net.js:1392:12)
    at Server.listen (net.js:1476:7)
    at Server.listen (C:UsersyuDocumentsGitHubBotBuilder-
SamplesNodecards-AdaptiveCards
ode_modules
estifylibserver.js:404:32)
    at Object.<anonymous> (C:UsersyuDocumentsGitHubBotBuilder-
SamplesNodecards-AdaptiveCardsapp.js:10:8)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)

I found some solution to this, It looks like the port 3978 was taken when I run the js file for the second time, and I have to use cmd to find which task is using that port, and then kill the task.

C:>netstat -aon|findstr 3978

so this one is taking the port, although I already closed all programs

TCP    0.0.0.0:3978           0.0.0.0:0              LISTENING       13140
TCP    [::]:3978              [::]:0                 LISTENING       13140

actually it is node.exe itself, it still running at background

C:Usersyu>tasklist|findstr 13140
node.exe                     13140 Console                    1     42,064 K

and I need to kill it

C:Usersyu>taskkill /f /t /im node.exe

Is there a way to not always repeat doing this when I want to run the file more than one time, it just starts to go wired today, and I mean for all different app.js files, include offical sample code. For the past one month, everything was fine, the IDE I am using is sublime text 3, node.js version is 8.9.4 lts

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is a very common issue and can be easily fixed by either of the below methods.

  1. Try to close the process that is using your port.

    netstat -tulnp | grep <port_number>

  2. Installing the below pakcage fixed it for me forever.

    npm install ws@3.3.2 --save-dev --save-exact

  3. Run this command in your terminal :

    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

    For Arch Linux add this line to /etc/sysctl.d/99-sysctl.conf:

    fs.inotify.max_user_watches=524288

    Then execute:

    sysctl --system

    This will also persist across reboots.

    https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details

Either one of the solutions will work . If not then restart your system and check again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...