Skip to content
This repository has been archived by the owner on Apr 1, 2018. It is now read-only.

TypeError: socket._receiver.flush is not a function #136

Open
cavebeat opened this issue Aug 17, 2017 · 5 comments
Open

TypeError: socket._receiver.flush is not a function #136

cavebeat opened this issue Aug 17, 2017 · 5 comments

Comments

@cavebeat
Copy link

When i set the nickname and press enter, following error occurs.

chat@chat:~$ cd hack.chat/
chat@chat:/home/chat/hack.chat$ node server.js
Loaded config 'config.json'
Started server on 0.0.0.0:6060
/home/chat/hack.chat/server.js:64
socket._receiver.flush();
^

TypeError: socket._receiver.flush is not a function
at WebSocket. (/home/chat/hack.chat/server.js:64:21)
at emitOne (events.js:115:13)
at WebSocket.emit (events.js:210:7)
at Receiver._receiver.onmessage (/home/chat/hack.chat/node_modules/ws/lib/WebSocket.js:146:47)
at Receiver.dataMessage (/home/chat/hack.chat/node_modules/ws/lib/Receiver.js:389:14)
at Receiver.getData (/home/chat/hack.chat/node_modules/ws/lib/Receiver.js:330:12)
at Receiver.startLoop (/home/chat/hack.chat/node_modules/ws/lib/Receiver.js:165:16)
at Receiver.add (/home/chat/hack.chat/node_modules/ws/lib/Receiver.js:139:10)
at Socket._ultron.on (/home/chat/hack.chat/node_modules/ws/lib/WebSocket.js:142:22)
at emitOne (events.js:115:13)
chat@chat:/home/chat/hack.chat$

root@chat:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.1 (stretch)
Release: 9.1
Codename: stretch

chat@chat:/home/chat/hack.chat$ node -v
v8.4.0

any idea what went wrong? Or what is missing?

@raf924
Copy link

raf924 commented Aug 17, 2017

hm yeah I think that code comes from a pull request that was done before the Andrew updated the ws dependency version. try to get the commit before last and see if that works

@cavebeat
Copy link
Author

cavebeat commented Aug 17, 2017

works with 5ca90f9

git checkout 5ca90f9

ping @marzavec

@raf924
Copy link

raf924 commented Aug 18, 2017

ok but did you try it with e60ac69 with [email protected] ?

@princenasario
Copy link

princenasario commented Mar 21, 2018

I tried it with every commit. I enter the username and it stays blank and when i send a text message, it says Server Disconnected error with the socket flush error in the terminal.

TypeError: socket._receiver.flush is not a function

Loaded config 'config.json'
Started server on 0.0.0.0:6060

/home/prince/hack.chat/server.js:64
socket._receiver.flush();
^

TypeError: socket._receiver.flush is not a function
at WebSocket. (/home/prince/hack.chat/server.js:64:21)
at emitOne (events.js:96:13)
at WebSocket.emit (events.js:191:7)
at Receiver._receiver.onmessage (/home/prince/hack.chat/node_modules/ws/lib/WebSocket.js:146:47)
at Receiver.dataMessage (/home/prince/hack.chat/node_modules/ws/lib/Receiver.js:389:14)
at Receiver.getData (/home/prince/hack.chat/node_modules/ws/lib/Receiver.js:330:12)
at Receiver.startLoop (/home/prince/hack.chat/node_modules/ws/lib/Receiver.js:165:16)
at Receiver.add (/home/prince/hack.chat/node_modules/ws/lib/Receiver.js:139:10)
at Socket._ultron.on (/home/prince/hack.chat/node_modules/ws/lib/WebSocket.js:142:22)

I tried every commit, including the latest commit. It doesn't work. What to do?

The npm error log file says:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 info lifecycle [email protected]
start: [email protected]
7 verbose lifecycle [email protected]start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/hom$9 verbose lifecycle [email protected]start: CWD: /home/prince/hack.chat
10 silly lifecycle [email protected]
start: Args: [ '-c', 'node server.js' ]
11 silly lifecycle [email protected]start: Returned: code: 1 signal: null
12 info lifecycle [email protected]
start: Failed to exec start script
13 verbose stack Error: [email protected] start: node server.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at EventEmitter.emit (events.js:194:7)
13 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:$13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:194:7)
13 verbose stack at maybeClose (internal/child_process.js:899:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/prince/hack.chat

@marzavec
Copy link
Contributor

@princenasario Cd into the directory where you have the server software, run the command:

npm list ws

If the output of npm is different than [email protected] then you need to remove ws and install version 1.1.1

However, that version of ws is old and slow (not to mention vulnerable to an upgrade header attack). The best recommendation I have is to not use the legacy version and instead use:

https://github.com/hack-chat/main

This is the current software running on https://hack.chat/, it uses version 5.0.0 of the ws library and has been proven stable with over 400 connections.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants