ClusterWS / cWS

DEPRECATED
Other
173 stars 25 forks source link

client side websocket option #30

Open jeonsy92 opened 4 years ago

jeonsy92 commented 4 years ago

I was trying to find out examples of websocket client which use perMessageDeflate option. But I couldn't find any example using even any other option. Is it possible to make PermessageDeflate false in client side? I'm trying to connect 3rd party websocket api and they set perMessageDeflate true. But what I want is perMessageDeflate option false because receiving data is small. I tried new WebSocket('url', {perMessageDeflate : false}); but didn't work I really want to use your library because it's so fast even in client perspective. Always thanks for great library.

goriunov commented 4 years ago

At the moment unfortunately there is no way to modify this option from the client side... Will add this to enhancement

jeonsy92 commented 4 years ago

Thank you for your fast reply. But I am doing project and don't have enough time. I want to make perMessageDeflate option false right away. So.. could you tell me which part of your code should I change not to use this option?

goriunov commented 4 years ago

@jeonsy92 by default cws client does not set perMessageDeflate, you can confirm that by running below script in compassing to ws. There is no way at the moment to enable this functionality on client which is added to enhancement....

// const WebSocket = require('ws');
const { WebSocket } = require('@clusterws/cws');

const { createServer } = require('http');

createServer((req, res) => {
  console.log(req.headers['sec-websocket-extensions']);
}).listen(3000, () => {
  new WebSocket('ws://localhost:3000');
});