1

I am trying to install websocket on nodejs with npm I am getting following error.. I am installing it on windows.

npm install websocket 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe', 1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'install', 1 verbose cli '[email protected]' ] 2 info using [email protected] 3 info using [email protected] 4 verbose node symlink C:\Program Files (x86)\nodejs\\node.exe 5 verbose config file C:\Users\tasleem\.npmrc 6 verbose config file C:\Program Files (x86)\nodejs\etc\npmrc 7 verbose config file C:\Program Files (x86)\nodejs\node_modules\npm\npmrc 8 verbose read json C:\Program Files (x86)\nodejs\package.json 9 verbose read json C:\Program Files (x86)\nodejs\node_modules\npm\package.json 10 verbose read json C:\Program Files (x86)\nodejs\node_modules\package\package.json 11 verbose read json C:\Program Files (x86)\nodejs\node_modules\websocket-1.0.6\package.json 12 verbose read json C:\Program Files (x86)\nodejs\package.json 13 verbose cache add [ '[email protected]', null ] 14 silly cache add name=undefined spec="[email protected]" args=["[email protected]",null] 15 verbose parsed url { pathname: '[email protected]', 15 verbose parsed url path: '[email protected]', 15 verbose parsed url href: '[email protected]' } 16 silly cache add name="websocket" spec="1.0.3" args=["websocket","1.0.3"] 17 verbose parsed url { pathname: '1.0.3', path: '1.0.3', href: '1.0.3' } 18 verbose addNamed [ 'websocket', '1.0.3' ] 19 verbose addNamed [ '1.0.3', '1.0.3' ] 20 verbose url raw websocket/1.0.3 21 verbose url resolving [ 'https://registry.npmjs.org/', './websocket/1.0.3' ] 22 verbose url resolved https://registry.npmjs.org/websocket/1.0.3 23 http GET https://registry.npmjs.org/websocket/1.0.3 24 error Error: connect ETIMEDOUT 24 error at errnoException (net.js:781:11) 24 error at Object.afterConnect [as oncomplete] (net.js:772:19) 24 error { [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect' } 25 error You may report this log at: 25 error <http://github.com/isaacs/npm/issues> 25 error or email it to: 25 error <[email protected]> 26 error System Windows_NT 6.1.7601 27 error command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "[email protected]" 28 error cwd C:\Program Files (x86)\nodejs 29 error node -v v0.8.0 30 error npm -v 1.1.32 31 error syscall connect 32 error code ETIMEDOUT 33 error message connect ETIMEDOUT 34 error errno ETIMEDOUT 35 error ETIMEDOUT errno 36 verbose exit [ 1, true ] 

Or I have got the WebSocket package , could someone tell where to extract this inside nodejs folder?

7
  • any reason why you would not just rely on socket.io to take care of web sockets for you? Commented Jun 26, 2012 at 6:24
  • No reason as such.. but I have not googled enough on Socket.io. Can it be integrated with nodejs? Commented Jun 26, 2012 at 6:35
  • There are many reasons, for example Socket.IO does not scale well. As for the question: it seems that this is a network problem. Commented Jun 26, 2012 at 6:36
  • so WebSocket is better than socket.io? @freakish Can you tell where to extract the WebSocket folder inside nodejs? Commented Jun 26, 2012 at 6:37
  • Not necessarly better - it depends on your needs. For example I use ws module. If you have WebSocket package, then you need to find a node_modules folder and extract it there. You may create one in your app's folder, if you wish to hold the library locally there. See this: nodejs.org/docs/v0.4.1/api/… Commented Jun 26, 2012 at 6:43

4 Answers 4

1

It seems that there is a connection problem between your site and the NPM registry. Try first to connect to NPM registry in a browser, you should have the same error.

Check your network connectivity, you can also try to ping registry.npmjs.org.

Sign up to request clarification or add additional context in comments.

4 Comments

It is opening in browser but from command prompt it is telling timed out. What could be the problem?
Do you have a proxy to access to the Internet?
No i don't have. I don't know whats wrong.. Ok apart from that. If I have a WebSocket package where should I put it to use?
@Fahad - are you able to install anything using npm with the current versions of node/npm at the moment?
0

a "npm up -g" cannot hurt either..

Comments

0

I am not sure if this can help you. I was using nodejs on windows via. Cygwin and when I tried making javascripts with websockets I had problems with the standard node installation - it was too old, I then tried to install a new version of node from inside Cygwin, however this was NOT possible, so I proceeded to install it using "node-v0.10.24-x64.msi" which can be downloaded from http://nodejs.org/download/

After download I then copied manually all contents from folder nodejs to cygwin /usr/local/bin

In order to install ws (websockets) then npm is needed and for that you need the newest version - after copying manually whole folder nodejs, then you can start cygwin and write following:

node -v

it should write something like this :

$ node -v

v0.10.24

now you can procede with following:

$ cd /usr/local/bin/node_modules/npm/bin

$ node npm-cli.js install ws

$ node npm-cli.js install websockets

the npm-cli.js is a command line interface version of npm, made in javascript and nodejs can parse it, so now ws module should be installed

-- NOTE it is very important that you copy or move the folder "node_modules" after the installation to following place :

cygwin/home/ --your user-- /node_modules

Otherwise your javascript projects will not beable to see the installed modules - it is actually strange why, but I have no answer for that - I just made a copy and then it worked

I hope you can use this answer

1 Comment

one extra thing - if you are considering using standard websocket with javascript, then make sure you follow HyBi-10 or later, since HyBi-00 is faulty - it is however in use in old mobile phones browsers - I unfortunately could not get basic connection working with HyBi-00, due to security reasons and I guess that is why HyBi-00 is discontinued and HyBi-10 is newest standard
0

Step1 : Set up server Express takes the role of HTTP server, serving HTML file and wiring Websocket service

var express = require('express') var ws = require('./ws') var app = express() app.get('/', function (req, res) { res.sendfile(__dirname + '/ws.html'); }) app.listen(3000, function () { console.log('app listening on port 3000!') }) 

Step2 : Set up Client websocket client is a browser supported object.

Below is goind to introduce 3 importand fucntion:

ws.onopen : emmited when connected ws.send : sending a send event to websocket server ws.onmessage : event emmited when receiving message

 <script> var ws = new WebSocket('ws://localhost:40510'); // event emmited when connected ws.onopen = function () { console.log('websocket is connected ...') // sending a send event to websocket server ws.send('connected') } // event emmited when receiving message ws.onmessage = function (ev) { console.log(ev); } </script> 

For ur reference : https://hackernoon.com/nodejs-web-socket-example-tutorial-send-message-connect-express-set-up-easy-step-30347a2c5535

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.