A
A
alexr1002017-01-15 23:03:00
Node.js
alexr100, 2017-01-15 23:03:00

Why is Node.js sending data uncompressed?

1) The data from the browser is in compressed form. (straight package). Packet 50 bytes without header.
2) The response from the server stubbornly goes in uncompressed form. Packet 250 bytes without header.
How to make it give compressed data.
socket.compression(true).emit - doesn't help.
socket.io 1.7.1

var express = require('express');
var io = require('socket.io');
var http = require('http');

var app = http.createServer();
var io = io.listen(app);
app.listen(3000);

io.sockets.on('connection', function (socket) {

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya Shatokhin, 2017-01-16
@iShatokhin

At the moment, compression is disabled in the settings, because. leads to memory leaks. You can try to enable it back through: You
can read about the problem here:
https://github.com/websockets/ws/issues/804

A
azabalkanskiy, 2017-01-16
@azabalkanskiy

I’ve recently been working on a node, I can be stupid, but in my express it doesn’t compress answers itself, try connecting require('compression')
var compression = require('compression')
var express = require('express')
var app = express()
// compress all requests
app.use(compression())

A
akzhan, 2017-01-16
@akzhan

In any case, it is advisable for you to put HA Proxy or nginx before node.
Give him a squeeze. At the same time, you can add modern Brotli compression.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question