theturtle32 / websocket-node Goto Github PK
View Code? Open in Web Editor NEWA WebSocket Implementation for Node.JS (Draft -08 through the final RFC 6455)
License: Apache License 2.0
A WebSocket Implementation for Node.JS (Draft -08 through the final RFC 6455)
License: Apache License 2.0
C:\websocket>npm install websocket
npm http GET https://registry.npmjs.org/websocket
[email protected] preinstall C:\Knowledge Management\Analytics\websocket\ws\nod
_modules\websocket
make validator
'make' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! [email protected] preinstall: make validator
npm ERR! cmd "/c" "make validator"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! make validator
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Program Fil
s (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "websocket"
npm ERR! cwd C:\Knowledge Management\Analytics\websocket\ws
npm ERR! node -v v0.6.13
npm ERR! npm -v 1.1.9
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: make validator
npm ERR! message cmd "/c" "make validator"
failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Knowledge Management\Analytics\websocket\ws\npm-debug.log
npm not ok
if i run in the chrome console:
websocket = new WebSocket('ws://****.l:8081/echo-protocol');
WebSocket
Unexpected response code: 500
the server just crashes with this exception:
Wed Jan 25 2012 22:12:42 GMT-0800 (PST) Server is listening on port 8080
/home/dev/.node_libraries/.npm/websocket/1.0.4/package/lib/WebSocketRequest.js:240
throw new Error("Specified protocol was not requested by the clien
^
Error: Specified protocol was not requested by the client.
at WebSocketRequest.accept (/home/dev/.node_libraries/.npm/websocket/1.0.4/package/lib/WebSocketRequest.js:240:19)
at WebSocketServer. (/var/www/pimcore-current/website/lib/socket_server.js:36:30)
at WebSocketServer.emit (events.js:81:20)
at WebSocketServer.handleUpgrade (/home/dev/.node_libraries/.npm/websocket/1.0.4/package/lib/WebSocketServer.js:179:14)
at Server. (native)
at Server.emit (events.js:81:20)
at Socket. (http.js:1035:14)
at Socket._onReadable (net.js:683:27)
at IOWatcher.onReadable as callback
using this example code:
var WebSocketServer = require('websocket').server;
var http = require('http');
var server = http.createServer(function(request, response) {
console.log((new Date()) + ' Received request for ' + request.url);
response.writeHead(404);
response.end();
});
server.listen(8081, function() {
console.log((new Date()) + ' Server is listening on port 8080');
});
wsServer = new WebSocketServer({
httpServer: server,
// You should not use autoAcceptConnections for production
// applications, as it defeats all standard cross-origin protection
// facilities built into the protocol and the browser. You should
// *always* verify the connection's origin and decide whether or not
// to accept it.
autoAcceptConnections: false
});
function originIsAllowed(origin) {
// put logic here to detect whether the specified origin is allowed.
return true;
}
wsServer.on('request', function(request) {
if (!originIsAllowed(request.origin)) {
// Make sure we only accept requests from an allowed origin
request.reject();
console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
return;
}
var connection = request.accept('echo-protocol', request.origin);
console.log((new Date()) + ' Connection accepted.');
connection.on('message', function(message) {
if (message.type === 'utf8') {
console.log('Received Message: ' + message.utf8Data);
connection.sendUTF(message.utf8Data);
}
else if (message.type === 'binary') {
console.log('Received Binary Message of ' + message.binaryData.length + ' bytes');
connection.sendBytes(message.binaryData);
}
});
connection.on('close', function(reasonCode, description) {
console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
});
});
any ideas?
Hi!
I want to implement a kind of outgoing queue for WebSocketConnection
. When flushing the queue, in order to proceed to the next element, I need to know whether #sendUTF()
was successful. How do I do that?
update: grepping the code for queue
showed you already have implemented the outgoing queue, but wiki says nothing. Would be great if you shed some light on this topic.
TIA,
--Vladimir
sudo ./npm install websocket
npm http GET https://registry.npmjs.org/websocket
npm http GET https://registry.npmjs.org/websocket
npm http GET https://registry.npmjs.org/websocket
npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.7.tgz
npm ERR! fetch failed https://registry.npmjs.org/websocket/-/websocket-1.0.7.tgz
npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.7.tgz
npm ERR! fetch failed https://registry.npmjs.org/websocket/-/websocket-1.0.7.tgz
npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.7.tgz
npm ERR! fetch failed https://registry.npmjs.org/websocket/-/websocket-1.0.7.tgz
npm ERR! Error: SSL Error: CERT_HAS_EXPIRED
npm ERR! at ClientRequest. (/home/roger/node-v0.8.8-linux-x64/lib/node_modules/npm/node_modules/request/main.js:525:26)
npm ERR! at ClientRequest.g (events.js:185:14)
npm ERR! at ClientRequest.EventEmitter.emit (events.js:88:17)
npm ERR! at HTTPParser.parserOnIncomingClient (http.js:1455:7)
npm ERR! at HTTPParser.parserOnHeadersComplete as onHeadersComplete
npm ERR! at CleartextStream.socketOnData (http.js:1366:20)
npm ERR! at CleartextStream.CryptoStream._push (tls.js:495:27)
npm ERR! at SecurePair.cycle (tls.js:849:20)
npm ERR! at EncryptedStream.CryptoStream.write (tls.js:230:13)
npm ERR! at Socket.ondata (stream.js:38:26)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]
npm ERR! System Linux 3.2.0-32-generic
npm ERR! command "/home/roger/node-v0.8.8-linux-x64/bin/node" "/home/roger/node-v0.8.8-linux-x64/bin/npm" "install" "websocket"
npm ERR! cwd /home/roger/node-v0.8.8-linux-x64/bin
npm ERR! node -v v0.8.8
npm ERR! npm -v 1.1.59
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/roger/node-v0.8.8-linux-x64/bin/npm-debug.log
npm ERR! not ok code 0
Also tried to load https://registry.npmjs.org/websocket/-/websocket-1.0.7.tgz in browser.
It response with "404 NOT FOUND"
The requested URL /websocket/-/websocket-1.0.7.tgz was not found on this server.
On Mac OS X, the native validator builds and works, but it generates warnings during the build process.
info it worked if it ends with ok
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/validation/src/validation.o
../src/validation.cc:144:31: warning: no newline at end of file
../src/validation.cc: In function ‘int is_valid_utf8(size_t, char*)’:
../src/validation.cc:71: warning: comparison between signed and unsigned integer expressions
../src/validation.cc:75: warning: comparison between signed and unsigned integer expressions
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
info done ok
I noticed this line: https://github.com/Worlize/WebSocket-Node/blob/v1.0.1/lib/WebSocketRequest.js#L263
It seems like this
refers to the anonymous function inside which the whole code block is. This almost looks like a bug, but my time and knowledge on this library is too limit to figure it out for sure.
I'm leaving this issue as a "check it and fix it if needed".
Note: there are other lines that use this
below.
Error expanding embedded variable.
ERR! Error: make
failed with exit code: 2
at Array.0 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:176:25)
at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! sh "-c" "node-gyp rebuild"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System FreeBSD 8.2-RELEASE
npm ERR! command "node" "/usr/local/bin/npm" "install" "websocket"
npm ERR! cwd /home/node/www
npm ERR! node -v v0.6.14
npm ERR! npm -v 1.1.12
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: node-gyp rebuild
npm ERR! message sh "-c" "node-gyp rebuild"
failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/node/www/npm-debug.log
npm not ok
Hi, i have issues with that when i'm sending a json object from my website to the websocket server, it just gets the '[object Object]' string, and not the real object, and vica versa, so i can't send any json object to the client from the server.
client-side javascript
var size = 65536+1;
var ba = new Uint8Array(size);
for (var i = 0; i < size; i++) {
ba[i] = 1;
}
var m = ba.buffer;
socket.binaryType = 'arraybuffer';
socket.send(m);
server-side javascript
connection.on('message', function(message) {
if (message.type === 'binary') {
console.log('Received Binary Message of ' + message.binaryData.length + ' bytes');
connection.sendBytes(message.binaryData);
}
});
Chromium 19.0.1070.0 (Developer Build 126631)
OS Windows
WebKit 536.3 (@110622)
JavaScript V8 3.9.13
Flash 11,1,102,63
User Agent Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1070.0 Safari/536.3
How to use websocket server with user authentication (with username and password)? If supplied password is not correct the server is expected to reject connection. Is it possible such authentication in handshaking? Or where to implement?
Hi, I was installing the module by using "npm install websocket"
The Error notice that "'v8.h' file not found".
I have no idea this problem. And I'm also pulzzed why should download the nodejs again that I was installed it before.
thanks for your advise.
shao19@mac:~/Code/svn.moko365.com/my/nodejs > npm install websocket --websocket:verbose
npm http GET https://registry.npmjs.org/websocket
npm http 304 https://registry.npmjs.org/websocket
[email protected] install /Users/shao19/Code/svn.moko365.com/my/nodejs/node_modules/websocket
node install.js
[websocket v1.0.7] Attempting to compile native extensions.
info it worked if it ends with ok
info downloading: http://nodejs.org/dist/v0.6.18/node-v0.6.18.tar.gz
spawn python [ '/Users/shao19/.node-gyp/0.6.18/tools/gyp_addon',
'binding.gyp',
'-I/Users/shao19/Code/svn.moko365.com/my/nodejs/node_modules/websocket/build/config.gypi',
'-f',
'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/validation/src/validation.o
../src/validation.cc:8:10: fatal error: 'v8.h' file not found
^
1 error generated.
make: *** [Release/obj.target/validation/src/validation.o] Error 1
ERR! Error: make
failed with exit code: 2
at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
at ChildProcess.emit (events.js:70:17)
at maybeExit (child_process.js:362:16)
at Process.onexit (child_process.js:398:5)
ERR! not ok
[websocket v1.0.7]
Native code compile failed!!
On Windows, native extensions require Visual Studio and Python.
On Unix, native extensions require Python, make and a C++ compiler.
Start npm with --websocket:verbose to show compilation output (if any).
[email protected] ./node_modules/websocket
Hi, I'm having this weird problem when I try to install websocket globally using npm -g
.
OS: OS X 10.7.4 (11.4.0 Darwin Kernel Version 11.4.0)
node.js: v0.8.1
npm: 1.1.33
I fails only when I use the -g
parameter.
martin@~/develop/nodejs$ sudo npm -g install websocket
npm http GET https://registry.npmjs.org/websocket
npm http 304 https://registry.npmjs.org/websocket
npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.6.tgz
npm http 200 https://registry.npmjs.org/websocket/-/websocket-1.0.6.tgz
> [email protected] install /usr/local/lib/node_modules/websocket
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! rebuild error Error: EACCES, mkdir '/Users/martin/.node-gyp'
gyp ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "-g" "install" "websocket"
npm ERR! cwd /Users/martin/develop/nodejs
npm ERR! node -v v0.8.1
npm ERR! npm -v 1.1.33
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/martin/develop/nodejs/npm-debug.log
npm ERR! not ok code 0
It says This is most likely a problem with the websocket package
but I'm really not able to figure out why.
Hello,
I tried to stress test my game server a bit today, which is using WebSocket-Node, by connecting 50 simultaneous bot players via your WebSocket-Node client. They are sending random messages to the server all the time, and it works fine until I disconnect them all at the same time.
The node.js server crashes, here is the error I get:
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'length' of null
at WebSocketConnection.processOutgoingFrameQueue (/home/node/.node_libraries/.npm/websocket/0.0.12/package/lib/WebSocketConnection.js:452:32)
at Array.<anonymous> (native)
at EventEmitter._tickCallback (node.js:126:26)
Weirdly enough, this only happens on my Joyent no.de server and not on my local dev OSX machine. I'm running node v0.4.10 locally, whereas v0.4.7 on the server where the crash happens.
For extra high scalability and the ability to handle arbitrarily large messages, there should be an optional Streaming API exposed to the application in addition to the Message-oriented and Frame-oriented APIs.
Hi there,
Npm seems to be complaining about not being able to validate the package for x64 architecture. I've been playing around with installing/uninstalling Visual Studio 2010 and the Windows 7 SDK. But I guess I only need Visual Studio 2010. Not sure what's going on. I'm running Windows 7 Home Premium 64-bit with Visual Studio 2010 installed.
$ npm install websocket
npm http GET https://registry.npmjs.org/websocket
npm http 304 https://registry.npmjs.org/websocket
npm WARN package.json [email protected] No README.md file found!
[email protected] install c:\Users\nils\workspace\node-projects\valgomat\node_modules\websocket
node-gyp rebuild
c:\Users\nils\workspace\node-projects\valgomat\node_modules\websocket>node "c:\Program Files\nodejs
node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7): erro
r MSB8007: The Platform for project 'validation.vcxproj' is invalid. Platform='x64'. You may be se
eing this message because you are trying to build a project without a solution file, and have speci
fied a non-default Platform that doesn't exist for this project. [c:\Users\nils\workspace\node-proj
ects\valgomat\node_modules\websocket\build\validation.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
failed with exit c
ode: 1
gyp ERR! stack at ChildProcess.onExit (c:\Program Files\nodejs\node_modules\npm\node_modules\nod
e-gyp\lib\build.js:215:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:674:10)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command "node" "c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin
node-gyp.js" "rebuild"
gyp ERR! cwd c:\Users\nils\workspace\node-projects\valgomat\node_modules\websocket
gyp ERR! node -v v0.8.6
gyp ERR! node-gyp -v v0.6.3
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! cmd "/c" "node-gyp rebuild"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "c:\Program Files\nodejs\node.exe" "c:\Program Files\nodejs\node_modules\npm
\bin\npm-cli.js" "install" "websocket"
npm ERR! cwd c:\Users\nils\workspace\node-projects\valgomat
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! c:\Users\nils\workspace\node-projects\valgomat\npm-debug.log
npm ERR! not ok code 0
I see in your whiteboard example that you are running everything under :
wsServer.on('request', function(request) {
...Now I see how to cause this to fire (set autoAcceptConnections: false, then do a "var connection = request.accept();" to accept all) but....
The question is....do I run everything under this instead of "on connect" like in your main example? Like listening for messages, etc?
I'm currently running everything under:
wsServer.on('connect', function(connection) {
But I need the request url (I think you call "resource").
Please advise. Thanks.
Joe
I need to close opened socket in web socket client, how can I do this?
PS. Sorry, I found it :)
the error shows:
[root@xen195v ~/yejianfeng/nodejs/chatdemo]# npm install websocket
npm http GET https://registry.npmjs.org/websocket
npm http 200 https://registry.npmjs.org/websocket
npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.6.tgz
npm http 200 https://registry.npmjs.org/websocket/-/websocket-1.0.6.tgz
[email protected] install /home/gaoyuan/yejianfeng/nodejs/chatdemo/node_modules/websocket
node-gyp rebuild
info it worked if it ends with ok
info downloading: http://nodejs.org/dist/v0.6.18/node-v0.6.18.tar.gz
spawn python [ '/home/gaoyuan/.node-gyp/0.6.18/tools/gyp_addon',
'binding.gyp',
'-I/home/gaoyuan/yejianfeng/nodejs/chatdemo/node_modules/websocket/build/config.gypi',
'-f',
'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory /home/gaoyuan/yejianfeng/nodejs/chatdemo/node_modules/websocket/build' CXX(target) Release/obj.target/validation/src/validation.o 在包含自 ../src/validation.cc:9 的文件中: /home/gaoyuan/.node-gyp/0.6.18/src/node.h:61:16: 警告:uv.h:没有那个文件或目录 ../src/validation.cc:144:31: 警告:文件未以空白行结束 /home/gaoyuan/.node-gyp/0.6.18/src/node.h:263: 错误:变量或字段 ‘SetErrno’ 声明为 void /home/gaoyuan/.node-gyp/0.6.18/src/node.h:263: 错误:‘uv_err_t’ 在此作用域中尚未声明 ../src/validation.cc: In function ‘int is_valid_utf8(size_t, char*)’: ../src/validation.cc:71: 警告:在有符号和无符号整数表达式间比较 ../src/validation.cc:75: 警告:在有符号和无符号整数表达式间比较 make: *** [Release/obj.target/validation/src/validation.o] 错误 1 make: Leaving directory
/home/gaoyuan/yejianfeng/nodejs/chatdemo/node_modules/websocket/build'
ERR! Error: make
failed with exit code: 2
at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:212:23)
at ChildProcess.emit (events.js:70:17)
at maybeExit (child_process.js:362:16)
at Process.onexit (child_process.js:398:5)
ERR! not ok
pm ERR! [email protected] install: node-gyp rebuild
npm ERR! sh "-c" "node-gyp rebuild"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 2.6.18-164.el5xen
npm ERR! command "node" "/usr/local/bin/npm" "install" "websocket"
npm ERR! cwd /home/gaoyuan/yejianfeng/nodejs/chatdemo
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.23
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: node-gyp rebuild
npm ERR! message sh "-c" "node-gyp rebuild"
failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/gaoyuan/yejianfeng/nodejs/chatdemo/npm-debug.log
npm not ok
and please kindly tell me how to fix this issue.
my node version: v0.6.18
Latest patched Snow Leopard.
I'm not very familiar with node or npm, so am not sure what info I can provid to help resolve this issue, please let me know.
I looked for duplicates of this, but only found references to bad OS X build environments. I build a lot of C modules, so I think that should be okay. I have used npm for a few modules, without problem, but do not know what was going on, didn't pay attention as there was no problem.
TIA
Lee
Lee:audio-live lee$ sudo npm install websocket --websocket:verbose
npm http GET https://registry.npmjs.org/websocket
npm http 304 https://registry.npmjs.org/websocket
[email protected] install /Users/lee/node_modules/websocket
node install.js
[websocket v1.0.7] Attempting to compile native extensions.
CXX(target) Release/obj.target/validation/src/validation.o
g++: error: x86_64: No such file or directory
g++: error: unrecognized option ‘-arch’
make: *** [Release/obj.target/validation/src/validation.o] Error 1
gyp ERR! rebuild error Error: make
failed with exit code: 2
gyp ERR! rebuild error at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:215:23)
gyp ERR! rebuild error at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! rebuild error at Process._handle.onexit (child_process.js:674:10)
gyp ERR! not ok
[websocket v1.0.7]
Native code compile failed!!
On Windows, native extensions require Visual Studio and Python.
On Unix, native extensions require Python, make and a C++ compiler.
Start npm with --websocket:verbose to show compilation output (if any).
[email protected] ../../../node_modules/websocket
Lee:audio-live lee$
Hi there,
I want to appologize beacuse i think that it's not new topic(as I read) and I don't want to disturb anybody. I tried to install it, but seems impossible and I think that I'm doing something wrong.
Requirements Information:
Xcode
(4.3) tools available in path: /Applications/Xcode.app/Contents/Developer/usr/bin/
(which
shows information for gcc
c++
and g++
).0.8.4
Node and finally i changed it to 0.6.13
as appear in README.md
as last option but result was the same.This is the stack (with node 0.6.13
):
ncpro:test_server makensi$ npm install websocket
npm http GET https://registry.npmjs.org/websocket
npm http 304 https://registry.npmjs.org/websocket
> [email protected] install /Users/makensi/Projects/workspace_node/test/test_server/node_modules/websocket
> node-gyp rebuild
info it worked if it ends with ok
spawn python [ '/Users/makensi/.node-gyp/0.6.13/tools/gyp_addon',
'binding.gyp',
'-I/Users/makensi/Projects/workspace_node/test/test_server/node_modules/websocket/build/config.gypi',
'-f',
'make' ]
spawn make [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/validation/src/validation.o
make: c++: No such file or directory
make: *** [Release/obj.target/validation/src/validation.o] Error 1
ERR! Error: `make` failed with exit code: 2
at Array.0 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:169:25)
at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "websocket"
npm ERR! cwd /Users/makensi/Projects/workspace_node/test/test_server
npm ERR! node -v v0.6.13
npm ERR! npm -v 1.1.9
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/makensi/Projects/workspace_node/test/test_server/npm-debug.log
npm not ok
If there is something else that you need, let me know it.
Thanks in advance.
Hello!
It looks like Chrome 16 now uses Draft 13... yet this server doesn't support it :
Fri Oct 14 2011 05:44:03 GMT-0400 (EDT) WebSocket: Invalid handshake: Unsupported websocket client version: 13
How can I help adding support?
Pleas add the url propertie to the connection object.
In the open issues in the readme you state: "Haven't tested TLS for the Server. (Perhaps this is handled automatically by attaching the WebSocket server to a https.createServer instead of http.createServer?) My server implements TLS via stunnel->haproxy->node."
I can confirm it works out of the box.
In the server example script I created a https server and at the client side I call "wss://".
Cheers,
Mark
Hello,
I have to use Opera 11 under Ubuntu in my work for some reason. Does websocket-node support the opera?
Thank you.
This is a minor tweak that would make life much easier. The connect and close events both pass the connection, but message does not. This makes things a bit awkward if you want to respond to the message. You're forced to use variables outside of the local scope.
This is easily changed by modifying WebSocketConnection.js on line 340, 356, 399, 405 from:
this.emit('message', {
to
this.emit('message', this, {
Thank you for this great library!
Hello.
Currently I am using Socket.IO wich is great but I need something fast like this.
Can someone show me an example of server/client with room support?
My idia is to make possible two users ( not more ) to chat together.
Thank you very much for the help.
Hi,
I tried to run the example, but I only got the following error:
server:
$ ./server.js
Sat Aug 06 2011 23:45:13 GMT+0200 (CEST) Server is listening on port 8080
Sat Aug 06 2011 23:45:17 GMT+0200 (CEST) Connection accepted.
Sat Aug 06 2011 23:45:19 GMT+0200 (CEST) WebSocket: Dropping Connection. Code: 1002 - Maximum message size exceeded.
Sat Aug 06 2011 23:45:19 GMT+0200 (CEST) Peer 127.0.0.1 disconnected.
client:
$ ./client.js
WebSocket client connected
Sat Aug 06 2011 23:45:19 GMT+0200 (CEST) Remote peer closed connection: Protocol Error - Description Provided: Maximum message size exceeded.
Connection Error: Error: ECONNRESET, Connection reset by peer
dumb-increment-protocol Connection Closed
What am I to do?
Thanks a lot
Thanks for the clean implementation of websockets for node... so much easier to work with than socket.io
Any chance you could add an easy way to require WebSocketConnection (eg in websocket.js)?
I'd like to use the CLOSE_REASON_* constants.
root@node:~# npm install -g websocket
[email protected] preinstall /usr/lib/node_modules/websocket
make validator
node-waf configure build
make: node-waf: Command not found
make: *** [validator] Error 127
npm ERR! error installing [email protected] Error: [email protected] preinstall: make validator
npm ERR! error installing [email protected] sh "-c" "make validator"
failed with 2
npm ERR! error installing [email protected] at ChildProcess. (/usr/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected] at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] preinstall: make validator
npm ERR! sh "-c" "make validator"
failed with 2
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! make validator
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 3.0.0-mammoth1
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "websocket"
npm ERR! cwd /root
npm ERR! node -v v0.4.9
npm ERR! npm -v 1.0.106
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /root/npm-debug.log
npm not ok
root@node:## cat /proc/version
root@node:
Linux version 3.0.0-mammoth1 (nats@nathan390) (gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) ) #2 SMP Fri Jul 22 16:45:39 EST 2011
root@node:~# uname -m
i686
node -v v0.8.2
npm -v 1.1.36
CentOS 5.6 Final
Error Message
npm http GET https://registry.npmjs.org/websocket
npm http 304 https://registry.npmjs.org/websocket
> [email protected] install /usr/local/www/PandaChat/node_modules/websocket
> node-gyp rebuild
/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp: line 2: node: command not found
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 127
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 2.6.18-238.el5
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "websocket"
npm ERR! cwd /usr/local/www/PandaChat
npm ERR! node -v v0.8.2
npm ERR! npm -v 1.1.36
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: `node-gyp rebuild`
npm ERR! message `sh "-c" "node-gyp rebuild"` failed with 127
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/local/www/PandaChat/npm-debug.log
npm ERR! not ok code 0
Using Chromium 22.0.1229.94 on debian sid (amd64) and node 0.9.0-pre, I cannot get the example code to work. When I enter
new WebSocket('ws://127.0.0.1:8080/')
in the chrome developer console, WebSocket crashes:
$ node wse.js
Warning: Native modules not compiled. XOR performance will be degraded.
Warning: Native modules not compiled. UTF-8 validation disabled.
Fri Jan 11 2013 09:35:38 GMT+0100 (CET) Server is listening on port 8080
/home/phihag/scratch/websockets/node_modules/websocket/lib/WebSocketRequest.js:288
throw new Error("Specified protocol was not requested by the clien
^
Error: Specified protocol was not requested by the client.
at WebSocketRequest.accept (/home/phihag/scratch/websockets/node_modules/websocket/lib/WebSocketRequest.js:288:19)
at WebSocketServer.<anonymous> (/home/phihag/scratch/websockets/wse.js:37:30)
at WebSocketServer.EventEmitter.emit (events.js:115:20)
at WebSocketServer.handleUpgrade (/home/phihag/scratch/websockets/node_modules/websocket/lib/WebSocketServer.js:189:14)
at Server.EventEmitter.emit (events.js:115:20)
at Socket.socket.ondata (http.js:1702:14)
at TCP.onread (net.js:404:27)
Hi
It turns out node.js sets a 120-sec read timeout at net.socket, which makes keepalive intervals higher than 120 secs useless, for this timeout's action is to close the socket
just setting such timeout to zero seems to do the trick:
wsServer.on ('request', function (request)
{
var connection = request.accept ('echo-test', request.origin);
connection.socket.setTimeout (0);
.
.
.
regards,
Hi,
Is it the case there there is a reliance on the Linux 'make' command? I'm running the new version of node.js for windows which works fine, but the install of websocket has an error.
Command Prompt:
npm install websocket
npm http GET https://registry.npmjs.org/websocket
npm http 200 https://registry.npmjs.org/websocket
npm http GET https://registry.npmjs.org/websocket/-/websocket-1.0.4.tgz
npm http 200 https://registry.npmjs.org/websocket/-/websocket-1.0.4.tgz[email protected] preinstall C:\Users\xyz
make validator
npm ERR! error installing [email protected]
npm ERR! [email protected] preinstall: make validator
npm ERR! cmd "/c" "make validator"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! make validator
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\Program Files\NodeJS\node.exe" "C:\Program Files\NodeJS\node_modules\npm\bin\npm-cli.js" "install" "websocket"
npm ERR! cwd C:\Users\xyz
npm ERR! node -v v0.6.7
npm ERR! npm -v 1.1.0-beta-10
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: make validator
npm ERR! message cmd "/c" "make validator"
failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\xyz
npm not ok
LOG FILE:
info it worked if it ends with ok
verbose cli [ 'C:\Program Files\NodeJS\node.exe',
verbose cli 'C:\Program Files\NodeJS\node_modules\npm\bin\npm-cli.js',
verbose cli 'install',
verbose cli 'websocket' ]
info using [email protected]
info using [email protected]
verbose config file C:\Users\User.npmrc
verbose config file C:\Program Files\NodeJS\etc\npmrc
verbose config file C:\Program Files\NodeJS\node_modules\npm\npmrc
verbose mkdir done: C:\Users\User\AppData\Roaming\npm 755
verbose mkdir done: C:\Users\User 755
verbose caching C:\Users\User\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\mime\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\net\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\ajax\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\express\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\webservice\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\jade\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\socket.io\package.json
verbose loadDefaults [email protected]
verbose caching C:\Users\User\node_modules\mongoose\package.json
verbose loadDefaults [email protected]
verbose from cache C:\Users\User\package.json
verbose into C:\Users\User [ 'websocket' ]
verbose cache add websocket
verbose cache add [ 'websocket', null ]
silly cache add: name, spec, args [ undefined, 'websocket', [ 'websocket', null ] ]
verbose parsed url { pathname: 'websocket', path: 'websocket', href: 'websocket' }
verbose addNamed [ 'websocket', '' ]
verbose addNamed [ null, '' ]
silly name, range, hasData [ 'websocket', '', false ]
verbose raw, before any munging websocket
verbose url resolving [ 'https://registry.npmjs.org/', './websocket' ]
verbose url resolved https://registry.npmjs.org/websocket
http GET https://registry.npmjs.org/websocket
http 200 https://registry.npmjs.org/websocket
silly get cb [ 200,
silly get cb { vary: 'Accept',
silly get cb server: 'CouchDB/1.1.0 (Erlang OTP/R14B04)',
silly get cb etag: '"45ABNZFQN6SUA7INPLX5GT9VG"',
silly get cb date: 'Mon, 13 Feb 2012 03:16:30 GMT',
silly get cb 'content-type': 'application/json',
silly get cb 'content-length': '36417' } ]
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Users\User\AppData\Roaming\npm-cache\websocket'
verbose mkdir done: C:\Users\User\AppData\Roaming\npm-cache\websocket 755
silly name, range, hasData 2 [ 'websocket', '', true ]
silly versions [ 'websocket',
silly versions [ '0.0.1',
silly versions '0.0.2',
silly versions '0.0.3',
silly versions '0.0.4',
silly versions '0.0.5',
silly versions '0.0.6',
silly versions '0.0.7',
silly versions '0.0.8',
silly versions '0.0.9',
silly versions '0.0.10',
silly versions '0.0.11',
silly versions '0.0.12',
silly versions '0.0.13',
silly versions '0.0.14',
silly versions '0.0.15',
silly versions '0.0.16',
silly versions '0.0.17',
silly versions '0.0.18',
silly versions '0.0.19',
silly versions '0.0.20',
silly versions '1.0.0',
silly versions '1.0.1',
silly versions '1.0.2',
silly versions '1.0.3',
silly versions '1.0.4' ] ]
verbose bin dist [ '0.6-ares1.7.5-DEV-evundefined-openssl0.9.8r-v83.6.6.15-win32-ia32-6.1.7600',
verbose bin dist { shasum: '1ceb545541dce5531c12187b80de902718a6afd2',
verbose bin dist tarball: 'http://registry.npmjs.org/websocket/-/websocket-1.0.4.tgz' } ]
verbose addRemoteTarball [ 'https://registry.npmjs.org/websocket/-/websocket-1.0.4.tgz',
verbose addRemoteTarball '1ceb545541dce5531c12187b80de902718a6afd2' ]
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610'1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549'
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Users\User
verbose mkdir done: C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549 7551.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\tmp.tgz
verbose fetch to C:\Users\User
verbose mkdir done: C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549 7551.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\tmp.tgz
http GET https://registry.npmjs.org/websocket/-/websocket-1.0.4.tgz
http 200 https://registry.npmjs.org/websocket/-/websocket-1.0.4.tgz
silly updated sha bytes 40960
silly updated sha bytes 34759
info shasum 1ceb545541dce5531c12187b80de902718a6afd2
info shasum C:\Users\User
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549___package.npm'1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549___package.npm 755
verbose mkdir done: C:\Users\User
verbose unpack_ uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549___package.npm\package
silly gunzTarPerm modes [ '755', '644' ]
silly afterUntar undefined
verbose gunzed C:\Users\User
verbose rm'ed C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549__package.npm\package',
verbose renamed [ 'C:\Users\User
verbose renamed 'C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package' ]1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package\package.json',
verbose has wscript [ undefined,
verbose has wscript { file: 'C:\Users\User
verbose has wscript contributors: false,
verbose has wscript serverjs: false,
verbose has wscript wscript: true } ]
verbose caching C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package\package.json1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package\package.json
verbose loadDefaults [email protected]
verbose tarball contents [ 'package', 'tmp.tgz' ]
verbose from cache C:\Users\User
verbose pack C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package.tgz
verbose pack C:\Users\User
silly makeList C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package\example\whiteboard\package.json
verbose caching C:\Users\User
verbose loadDefaults [email protected]
silly dir, dirLen [ 'C:\Users\User1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package\example\whiteboard',1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package',
silly dir, dirLen 120 ]
silly dir, dirLen [ 'C:\Users\User
silly dir, dirLen 101 ]
verbose tarball C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package.tgz
verbose parent C:\Users\User~1.CAN\AppData\Local\Temp\npm-1329102991610\1329102991610-0.07118203863501549\package
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4___package.npm'
verbose mkdir done: C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4___package.npm 755
verbose unpack uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package
silly gunzTarPerm modes [ '755', '644' ]
silly afterUntar undefined
verbose gunzed C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4___package.npm\package
verbose rm'ed C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package
verbose renamed [ 'C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4___package.npm\package',
verbose renamed 'C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package' ]
verbose has wscript [ undefined,
verbose has wscript { file: 'C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package\package.json',
verbose has wscript contributors: false,
verbose has wscript serverjs: false,
verbose has wscript wscript: true } ]
verbose caching C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package\package.json
verbose loadDefaults [email protected]
silly updated sha bytes 40960
silly updated sha bytes 34654
info shasum 1d89b807f2524a6cfacd152271d1bbf5f369cba6
info shasum C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package.tgz
verbose from cache C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package\package.json
verbose chmod C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package.tgz 644
silly skipping chown for windows C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package.tgz
silly resolved [ { name: 'websocket',
silly resolved description: 'Websocket Client & Server Library tracking the latest protocol drafts from the IETF.',
silly resolved keywords: [ 'websocket', 'socket', 'networking', 'comet', 'push' ],
silly resolved author: { name: 'Brian McKelvey', email: '[email protected]' },
silly resolved version: '1.0.4',
silly resolved repository:
silly resolved { type: 'git',
silly resolved url: 'git://github.com/Worlize/WebSocket-Node.git' },
silly resolved engines: { node: '>=0.4.7' },
silly resolved scripts: { preinstall: 'make validator' },
silly resolved main: 'index',
silly resolved directories: { lib: './lib' },
silly resolved _id: '[email protected]',
silly resolved dependencies: {},
silly resolved devDependencies: {},
silly resolved _engineSupported: true,
silly resolved _npmVersion: '1.1.0-beta-10',
silly resolved _nodeVersion: 'v0.6.7',
silly resolved defaultsLoaded: true,
silly resolved dist: { shasum: '1d89b807f2524a6cfacd152271d1bbf5f369cba6' } } ]
info into C:\Users\User [email protected]
info installOne [email protected]
info unbuild C:\Users\User\node_modules\websocket
verbose from cache C:\Users\User\AppData\Roaming\npm-cache\websocket\1.0.4\package\package.json
verbose mkdir (expected) error ENOENT, no such file or directory 'C:\Users\User\node_modules___websocket.npm'
verbose mkdir done: C:\Users\User\node_modules___websocket.npm 755
verbose unpack uid, gid [ undefined, undefined ]
verbose unpackTarget C:\Users\User\node_modules\websocket
silly gunzTarPerm modes [ '755', '644' ]
silly afterUntar undefined
verbose gunzed C:\Users\User\node_modules___websocket.npm\package
verbose rm'ed C:\Users\User\node_modules\websocket
verbose renamed [ 'C:\Users\User\node_modules___websocket.npm\package',
verbose renamed 'C:\Users\User\node_modules\websocket' ]
verbose has wscript [ undefined,
verbose has wscript { file: 'C:\Users\User\node_modules\websocket\package.json',
verbose has wscript contributors: false,
verbose has wscript serverjs: false,
verbose has wscript wscript: true } ]
verbose caching C:\Users\User\node_modules\websocket\package.json
verbose loadDefaults [email protected]
info preinstall [email protected]
verbose unsafe-perm in lifecycle true
silly exec cmd "/c" "make validator"
silly spawning [ 'cmd',
silly spawning [ '/c', 'make validator' ],
silly spawning 'C:\Users\User\node_modules\websocket' ]
info [email protected] Failed to exec preinstall script
ERR! error installing [email protected]
info unbuild C:\Users\User\node_modules\websocket
verbose from cache C:\Users\User\node_modules\websocket\package.json
info preuninstall [email protected]
info uninstall [email protected]
verbose unbuild [email protected] [ true,
verbose unbuild [email protected] 'C:\Users\User\node_modules',
verbose unbuild [email protected] 'C:\Users\User\node_modules' ]
info postuninstall [email protected]
verbose installOne cb [email protected]
ERR! [email protected] preinstall: make validator
ERR! cmd "/c" "make validator"
failed with 1
ERR!
ERR! Failed at the [email protected] preinstall script.
ERR! This is most likely a problem with the websocket package,
ERR! not with npm itself.
ERR! Tell the author that this fails on your system:
ERR! make validator
ERR! You can get their info via:
ERR! npm owner ls websocket
ERR! There is likely additional logging output above.
ERR!
ERR! System Windows_NT 6.1.7600
ERR! command "C:\Program Files\NodeJS\node.exe" "C:\Program Files\NodeJS\node_modules\npm\bin\npm-cli.js" "install" "websocket"
ERR! cwd C:\Users\User
ERR! node -v v0.6.7
ERR! npm -v 1.1.0-beta-10
ERR! code ELIFECYCLE
ERR! message [email protected] preinstall: make validator
ERR! message cmd "/c" "make validator"
failed with 1
verbose exit [ 1, true ]
Hi,
I am using websocket for my server. I am using http.createServer
instance for static file server also. My problem is say a client hits my server and after that he goes into idle. After a while my server shuts down and shows the following message:
throw e; // process.nextTick error, or 'error' event on first tick
Please help me to resolve the issue.
Hello
Maybe I am not looking in the right place but i can't find a method to list all connected sessions or to send data only to specific session.
Can you please point me in the right direction ?
Is it possible to set a http proxy for the WebSocketClient?
I'm just using the client part, connect to a proxy server as format
ws://proxyserer:80/proxy?type=.. , after handskake success, when call send, then an onclose event happen.
Can we support the usage of client part to connect a proxy server?
Can you please tell me how to find and use the connectionid?
The server I'm currently using (node-websocket-server) lets me pull a conn.id so I can use it for things like redis, etc....specifically for a given socket connection.
Can you help me find that here? I must have just missed it. Thanks.
Joe
Hi WebSocket author,
First of all, thank you so very much for your work, this package is damm awesome.
Recently I have noticed that connections are not being validated, so I opened up firebug and saw this:
HTTP/1.1 400 Bad Request
Connection: close
X-WebSocket-Reject-Reason: Cannot read property '1' of null
That was quite obviosuly a JS error which was try{} catch(e) {writeHeader(X-WebSocket-Reject-Reason, e.message) }
So I did some hacking and found the problem for you:
// this codes throws an error
WebSocketRequest.prototype.parseCookies = function(cookieString) {
if (!cookieString || cookieString.length === 0) {
return [];
}
var cookies = [];
var cookieArray = cookieString.split(cookieSeparatorRegEx);
cookieArray.forEach(function(cookie) {
if (cookie && cookie.length !== 0) {
var cookieParts = cookie.match(cookieCaptureRegEx);
cookies.push({
name: cookieParts[1],
value: cookieParts[2]
});
}
});
return cookies;
};
// this code catches it
WebSocketServer.prototype.handleUpgrade = function(request, socket, head) {
var wsRequest = new WebSocketRequest(socket, request, this.config);
try {
wsRequest.readHandshake();
}
catch(e) {
wsRequest.reject(
e.httpCode ? e.httpCode : 400,
e.message,
e.headers
);
if (Constants.DEBUG) {
console.error((new Date()) + " WebSocket: Invalid handshake: " + e.message);
}
return;
}
wsRequest.once('requestAccepted', this._handlers.requestAccepted);
if (!this.config.autoAcceptConnections && this.listeners('request').length > 0) {
this.emit('request', wsRequest);
}
else if (this.config.autoAcceptConnections) {
wsRequest.accept(wsRequest.requestedProtocols[0], wsRequest.origin);
}
else {
wsRequest.reject(404, "No handler is configured to accept the connection.");
}
};
Here is a stack trace:
TypeError: Cannot read property '1' of null
at WebSocketRequest.parseCookies (/home/roderick/Desktop/Harmony/node_modules/websocket/lib/WebSocketRequest.js:202:34)
at Array.forEach (native)
at WebSocketRequest.parseCookies (/home/roderick/Desktop/Harmony/node_modules/websocket/lib/WebSocketRequest.js:198:17)
at WebSocketRequest.readHandshake (/home/roderick/Desktop/Harmony/node_modules/websocket/lib/WebSocketRequest.js:162:25)
at WebSocketServer.handleUpgrade (/home/roderick/Desktop/Harmony/node_modules/websocket/lib/WebSocketServer.js:162:19)
at Server.EventEmitter.emit (events.js:115:20)
at CleartextStream.socket.ondata (http.js:1702:14)
at CleartextStream.CryptoStream._push (tls.js:396:27)
at SecurePair.cycle (tls.js:750:20)
at EncryptedStream.CryptoStream.write (tls.js:131:13)
and here is the fix:
WebSocketRequest.prototype.parseCookies = function(cookieString) {
if (!cookieString || cookieString.length === 0) {
return [];
}
var cookies = [];
var cookieArray = cookieString.split(cookieSeparatorRegEx);
cookieArray.forEach(function(cookie) {
if (cookie && cookie.length !== 0) {
var cookieParts = cookie.match(cookieCaptureRegEx);
if (!cookieParts) {
return;
}
cookies.push({
name: cookieParts[1],
value: cookieParts[2]
});
}
});
return cookies;
};
Any questions let me know.
Ubuntu: 10.10, python 2.6.6, node.js 0.8.6(0.8.8), gun make 3.81, gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)
when I install websocket:
[email protected] install /home/stream/Program/node-v0.8.6/deps/npm/node_modules/websocket
node install.js
Native code compile failed!!
On Windows, native extensions require Visual Studio and Python.
gyp
failed with exit code: 2Native code compile failed!!
On Unix, native extensions require Python, make and a C++ compiler.
Please help me, thank you!
Hi,
I have deployed websocket application on amazon ec2 server and problem I am facing is the process eats memory and it gets increased with uptime, and crashes often.
Code of server is here, please help.
// http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
"use strict";
// Optional. You will see this name in eg. 'ps' or 'top' command
process.title = 'Mindspark';
// Port where we'll run the websocket server
var webSocketsServerPort = 8999;
// websocket and http servers
var webSocketServer = require('websocket').server;
var http = require('http');
/**
* Global variables
*/
// latest 100 messages
// list of currently connected clients (users)
var clients = [ ];
var userData = [ ];
var liveUsers = [ ];
var decodedData = [ ];
/**
* Helper function for escaping input strings
*/
function htmlEntities(str) {
return String(str).replace(/&/g, '&').replace(/</g, '<')
.replace(/>/g, '>').replace(/"/g, '"');
}
// Array with some colors
//var colors = [ 'red', 'green', 'blue', 'magenta', 'purple', 'plum', 'orange' ];
// ... in random order
//colors.sort(function(a,b) { return Math.random() > 0.5; } );
/**
* HTTP server
*/
var server = http.createServer(function(request, response) {
// Not important for us. We're writing WebSocket server, not HTTP server
});
server.listen(webSocketsServerPort, function() {
// console.log((new Date()) + " Server is listening on port " + webSocketsServerPort);
});
/**
* WebSocket server
*/
var wsServer = new webSocketServer({
// WebSocket server is tied to a HTTP server. WebSocket request is just
// an enhanced HTTP request. For more info http://tools.ietf.org/html/rfc6455#page-6
httpServer: server
});
// This callback function is called every time someone
// tries to connect to the WebSocket server
wsServer.on('request', function(request) {
//console.log((new Date()) + ' Connection from origin ' + request.origin + '.');
// accept connection - you should check 'request.origin' to make sure that
// client is connecting from your website
// (http://en.wikipedia.org/wiki/Same_origin_policy)
var origin = request.origin
origin = origin.replace('http://', '');
origin = origin.replace('https://', '');
origin = origin.replace('www.', '');
origin = origin.replace('/', '');
if(!(origin == "localhost" || origin == "192.168.0.99"))
{
console.log("Access denied for: "+request.origin)
return false;
}
var connection = request.accept(null, request.origin);
// we need to know client index to remove them on 'close' event
var index = clients.push(connection) - 1;
var userName = false;
//console.log((new Date()) + ' Connection accepted.');
// send back chat history
/*if (history.length > 0) {
connection.sendUTF(JSON.stringify( { type: 'history', data: history} ));
}*/
// user sent some message
connection.on('message', function(message) {
if (message.type === 'utf8') {
var parseMsg = JSON.parse(message.utf8Data);
//console.log(decodedData['data']);
if(parseMsg['data'] == "")
parseMsg['data'] = null;
decodedData = parseMsg['data'];
var actionName = '_action'+parseMsg['action'].charAt(0).toUpperCase()+parseMsg['action'].slice(1);
eval(''+actionName+'('+index+')');
}
});
// user disconnected
connection.on('close', function(connection) {
// remove user from the list of connected clients
userData[index] = null;
liveUsers[index] = null;
_actionInit(0);
});
});
function _actionQuestionAttempted(index)
{
var data = decodedData;
if(typeof userData[index] == 'undefined')
userData[index] = [];
userData[index] = {"userID":data["userID"],"pictureURL":data["pictureURL"],"childName":data["name"],"enrollmentID":data["enrollmentID"],"stBatchID":data["stBatchID"],"centerName":data["centerName"],"mathLevel":data["mathLevel"],"langLevel":data["langLevel"],"childClass":data["childClass"],"sessionType":data["sessionType"],"sessionID":data["sessionID"],"totalQ":data["totalQ"],"totalC":data["totalC"]};
var json = JSON.stringify({ action:'userData', data: userData });
for (var i=0; i < clients.length; i++)
{
clients[i].sendUTF(json);
}
}
function _actionPing(index)
{
var data = decodedData;
if(typeof liveUsers[index] == 'undefined')
liveUsers[index] = [];
liveUsers[index] = {"userID":data["userID"],"status":data["status"],"sessionType":data["sessionType"]};
var json = JSON.stringify({ action:'liveUsers', data: liveUsers });
for (var i=0; i < clients.length; i++)
{
clients[i].sendUTF(json);
}
}
function _actionInit(index)
{
var json = JSON.stringify({ action:'liveUsers', data: liveUsers });
for (var i=0; i < clients.length; i++)
{
clients[i].sendUTF(json);
}
var json = JSON.stringify({ action:'userData', data: userData });
for (var i=0; i < clients.length; i++)
{
clients[i].sendUTF(json);
}
}
function _actionClearMemory(index)
{
liveUsers = [];
userData = [];
}
iOS failing at handshake
Hi,
This is only a minor issue and in all honesty can be fixed either via doco or not at all.
Just that I tried recently to implement ssl and presumed that there would be an option for httpsServer, as there is currently an option for httpServer. Turns out there isn't and must use httpServer.
If you do not specify httpServer then WebSocketServer throws the exception "You must specify an httpServer on which to mount the WebSocket server."
It just threw me for a little bit until I figured out that I just set httpServer to the https server that I created.
As I said, it's not a biggie, just a tad confusing is all.
I'm actually curious if it would make sense to be able to specify both a httpServer and httpsServer for the same websocket, would that make sense? Right now I'm creating two instances and setting one to the http server and one to the https server.
Cheers,
James.
If the client attaching to the server states the available protocol with any characters in upper-case then there is no way to accept the connection.
This is because the on request event is passing the requested protocols as all lower-case. So even if the code checks for the first requested protocol and passes it back, the client will reject it as it does not match.
The specification states:
The elements that comprise this value MUST be non-empty strings with characters in the range U+0021 to U+007E not including separator characters as defined in [RFC2616] and MUST all be unique strings.
(refer RFC6455 page 18 point 10).
So it's clear that it can support upper case characters.
Cheers,
James.
PS. loving this extension for nodejs, this is the only hiccup I've had and I can work around by just not using upper case.
Hi,
I was trying to install websocket and got following error:
$sudo npm install websocket
[sudo] password:
npm WARN [email protected] package.json: bugs['web'] should probably be bugs['url']
[email protected] preinstall /home/kumar/node_modules/websocket
node-gyp configure
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: Invalid protocol
gyp ERR! stack at Request.init (/home/kumar/node_modules/node-gyp/node_modules/request/main.js:291:31)
gyp ERR! stack at new Request (/home/kumar/node_modules/node-gyp/node_modules/request/main.js:103:8)
gyp ERR! stack at request (/home/kumar/node_modules/node-gyp/node_modules/request/main.js:858:11)
gyp ERR! stack at download (/home/kumar/node_modules/node-gyp/lib/install.js:132:15)
gyp ERR! stack at /home/kumar/node_modules/node-gyp/lib/install.js:203:17
gyp ERR! stack at Object.oncomplete (/home/kumar/node_modules/node-gyp/node_modules/mkdirp/index.js:46:26)
gyp ERR! System Linux 2.6.32-5-686
gyp ERR! command "node" "/home/kumar/node_modules/.bin/node-gyp" "configure"
gyp ERR! cwd /home/kumar/node_modules/websocket
gyp ERR! node -v v0.6.4
gyp ERR! node-gyp -v v0.6.2
gyp ERR! This is a bug in node-gyp
.
gyp ERR! Please file an Issue:
gyp ERR! https://github.com/TooTallNate/node-gyp/issues
npm ERR! error installing [email protected] Error: [email protected] preinstall: node-gyp configure
npm ERR! error installing [email protected] sh "-c" "node-gyp configure"
failed with 7
npm ERR! error installing [email protected] at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected] at ChildProcess.emit (events.js:70:17)
npm ERR! error installing [email protected] at maybeExit (child_process.js:359:16)
npm ERR! error installing [email protected] at Process.onexit (child_process.js:395:5)
[email protected] preuninstall /home/kumar/node_modules/websocket
node-gyp clean
npm ERR! [email protected] preinstall: node-gyp configure
npm ERR! sh "-c" "node-gyp configure"
failed with 7
npm ERR!
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 2.6.32-5-686
npm ERR! command "node" "/usr/local/bin/npm" "install" "websocket"
npm ERR! cwd /home/kumar/sandbox/node-js/websoket
npm ERR! node -v v0.6.4
npm ERR! npm -v 1.1.0-alpha-6
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] preinstall: node-gyp configure
npm ERR! message sh "-c" "node-gyp configure"
failed with 7
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/kumar/sandbox/node-js/websoket/npm-debug.log
npm not ok
Validation seems not to work with 1.0.6 package (used by socket.io) after upgrade to node 0.8.0
websocket/lib/Validation.js:17
throw e;
^
Error: Cannot find module '../build/default/validation'
Troubleshoot : doing a npm install [email protected]
seems to fix the problem ( as there is no native module used )
It will be important to support both reading and setting cookie values as the needs of WebSocket browser clients expand and become more complex.
The accept() method of WebSocketRequest should take an additional third parameter, "cookies", that is an array of objects. Each of which is the definition of a cookie to set in the browser, and each of which will generate a "Set-Cookie" header sent in the response to the client.
The WebSocketRequest should also expose a new property, "cookies" that is an Object consisting of Key/Value pairs from the parsed Cookie header.
Once both of these features are complete, a new version of WebSocket-Node will be released.
When using node install websocket, the result is as below:
Your environment has been set up for using Node.js 0.8.2 (x64) and NPM
C:\Program Files\nodejs\node_modules\npm\node_modules>npm install websocket
npm http GET https://registry.npmjs.org/websocket
npm http 304 https://registry.npmjs.org/websocket
[email protected] install C:\Program Files\nodejs\node_modules\npm\node_modules
websocket
node-gyp rebuild
C:\Program Files\nodejs\node_modules\npm\node_modules\websocket>node "C:\Program
Files\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin
\node-gyp.js" rebuild
validation.cc
..\src\validation.cc(8): fatal error C1083: Cannot open include file: 'v8.h': N
o such file or directory [C:\Program Files\nodejs\node_modules\npm\node_modules
\websocket\build\validation.vcxproj]
gyp ERR! rebuild error Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msb uild.exe
failed with exit code: 1
gyp ERR! rebuild error at ChildProcess.onExit (C:\Program Files\nodejs\node_
modules\npm\node_modules\node-gyp\lib\build.js:214:23)
gyp ERR! rebuild error at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! rebuild error at Process._handle.onexit (child_process.js:674:10)
gyp ERR! not ok
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! cmd "/c" "node-gyp rebuild"
failed with 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the websocket package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls websocket
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nod
ejs\node_modules\npm\bin\npm-cli.js" "install" "websocket"
npm ERR! cwd C:\Program Files\nodejs\node_modules\npm\node_modules
npm ERR! node -v v0.8.2
npm ERR! npm -v 1.1.36
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: node-gyp rebuild
npm ERR! message cmd "/c" "node-gyp rebuild"
failed with 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Program Files\nodejs\node_modules\npm\node_modules\npm-debug.log
npm ERR! not ok code 0
I'm not sure if this is an issue with the implementation of WebSocket-Node, or Chrome, or if I'm just doing it wrong, but.... WebSocketRequest::reject takes a status code and a reason, but when I call it I can't seem to get the status code or the reason in my client code.
-Server-
var http = require('http');
var httpServer = http.createServer(function (request, response)
{
// i see this if i hit http://localhost:8001/
response.end('go away');
});
httpServer.listen(8001);
// https://github.com/Worlize/WebSocket-Node/wiki/Documentation
var webSocket = require('websocket');
var webSocketServer = new webSocket.server({ 'httpServer': httpServer });
webSocketServer.on('request', function (request)
{
var connection = request.reject(102, 'gtfo');
});
-Client-
var connection = new WebSocket('ws://127.0.0.1:8001');
connection.onopen = function (openEvent)
{
alert('onopen');
console.log(openEvent);
};
connection.onclose = function (closeEvent)
{
alert('onclose');
console.log(closeEvent);
}
connection.onerror = function (errorEvent)
{
alert('onerror');
console.log(errorEvent);
};
connection.onmessage = function (messageEvent)
{
alert('onmessage');
console.log(messageEvent);
};
Only the OnClose
event fires, but there isn't a status code or message in the closeEvent object that I can find. Any ideas?
I created a question on SO 2 weeks back, but didn't get much of a response:
http://stackoverflow.com/questions/10560591/nodejs-websockets-reject-the-connection-with-a-message
The native validator is built using node-waf, which is not available on Windows or OSX prebuilt nodejs installations. It is therefore not possible to install this package using NPM on these systems.
Would it be possible to make the validator optional, or to skip its installation if there is no node-waf?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.