hack.chat
hack.chat copied to clipboard
TypeError: socket._receiver.flush is not a function
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?
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
works with https://github.com/AndrewBelt/hack.chat/commit/5ca90f990cacbb7c7ac7c6156929baabb5a3121c
git checkout 5ca90f990cacbb7c7ac7c6156929baabb5a3121c
ping @marzavec
ok but did you try it with e60ac6936547341c67afdfff327ac40f6da2273b with [email protected] ?
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.
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.
@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.