Socket.io server crash on client connect @1.7.3 due to bufferutil and utf-8-validate
See original GitHub issueNote: for support questions, please use one of these channels: stackoverflow or slack
You want to:
- report a bug
- request a feature
Current behaviour
Steps to reproduce (if the current behaviour is a bug)
- Start headless socket.io server with:
require('dotenv').config();
var Server = require('socket.io');
var io = new Server();
io.on('connection', function(client){
console.log("a new connection was received!");
client.on('request_payload', function (from, msg) {
console.log('I received a private message by ', from, ' saying ', msg);
});
client.on('disconnect', function(){
console.error("Client disconnected!");
})
});
console.log(`Started socket server on port ${process.env.SOCKET_SERVER_PORT}`);
io.listen(process.env.SOCKET_SERVER_PORT);
- Attempt client side connection with socket.io-client@1.7.3
var socket = io(`ws://127.0.0.1:9090/`);
socket.on('connect', function(){
console.log('connected!');
});
socket.on('event', function(data){});
socket.on('disconnect', function(){
console.log('disconnected');
});
Note that I’m using webpack as my build system, and taking in socket.io-client through an import instead of it being served down in the /socket.io
route like it usually should, though I doubt this should matter.
The server runs fine if there are no incoming connections. As soon as a client tries to connect I get the issue seen below.
Expected behaviour
Not crash
Setup
- OS: Windows and Linux (ubuntu)
- browser: Chrome
- socket.io version: 1.7.3
Other information (e.g. stacktraces, related issues, suggestions how to fix)
Node version: 7.5.0
> node socketapp/server.js
Started socket server on port 9090
a new connection was received!
C:\Users\Coop\Documents\Github\lora_demo_server\node_modules\ws\lib\Receiver.js:306
if (mask != null && buf != null) bufferUtil.unmask(buf, mask);
^
TypeError: Cannot read property 'unmask' of undefined
at Receiver.unmask (C:\Users\Coop\Documents\Github\lora_demo_server\node_modules\ws\lib\Receiver.js:306:46)
at Receiver.finish (C:\Users\Coop\Documents\Github\lora_demo_server\node_modules\ws\lib\Receiver.js:505:25)
at Receiver.expectHandler (C:\Users\Coop\Documents\Github\lora_demo_server\node_modules\ws\lib\Receiver.js:493:33)
at Receiver.add (C:\Users\Coop\Documents\Github\lora_demo_server\node_modules\ws\lib\Receiver.js:103:24)
at Socket.realHandler (C:\Users\Coop\Documents\Github\lora_demo_server\node_modules\ws\lib\WebSocket.js:825:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:189:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:551:20)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Socket.io server crash on client connect @1.7.3 due to ...
Socket.io server crash on client connect @1.7.3 due to bufferutil and utf-8-validate.
Read more >NodeJS + Socket.io unhandled error event on connection from ...
Everything works fine during the day (clients connect, disconnect without crashing the server) but sometime overnight it crashes (happens about ...
Read more >Open Source Used In NFVIS 3.6.1 - Cisco
This document contains licenses and notices for open source software used in this product. With respect to the free/open source software listed in...
Read more >Implementing a Crash-Resistant Socket.io Service Without ...
One can attach any data to this attribute, then call fetchSockets to view the data associated with other connected clients, no matter which...
Read more >npm-debug.log - Sangoma Issue Tracker
It should not be used in real code due to the implied hazards. ... '644' ] 13212 silly prepareForInstallMany adding backo2@1.0.2 from socket.io-client...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like this is an issue with the
ws
module. Installing thebufferutil
andutf-8-validate
modules, as per reccomendation on their npm page breaks the module. The issue seems to be that the api that they use for the mocks doesnt match the api for the most updated versions of these modules. Weird because they list the most updated version of these in their package.json.Performing an
npm remove bufferutil
andnpm remove utf-8-validate
after installation of socket.io seemed to have resolved the issue.Installing the versions ws@1.1.2 requires worked for me: