profile
viewpoint

HenningM/express-ws 633

WebSocket endpoints for express applications

joepie91/anonnews2 20

The source code for the current http://anonnews.org/ (AnonNews 2.0) The current rewrite, version 3.0, will live in a separate repository.

arkbg1/BitVote 14

Protecting Ethereum from Social and Political Attacks

joepie91/BlueCP 3

A web hosting panel based on PHP.

joepie91/4chandownloader 2

[unmaintained] Simple tool to download a 4chan thread.

joepie91/beautifulsoup 2

My fork of BeautifulSoup, primarily to add more support for CSS selectors. Supports basic :nth-of-type() pseudoselectors and non-tag selectors as direct descendants.

ConnectU/logicmon-azure-config 1

NodeJS and Electron mechanism for configuring some azure settings

joepie91/binder 1

Binder is a lightweight SQL mapper for Python

joepie91/blogger-discovery 1

Discovering blogger blogs using the profile pages

joepie91/book 1

Crypto 101, the introductory book on cryptography.

issue commentHenningM/express-ws

This project seems to be dead

@andraz213 Since you're in control of the client, you could always just open an HTTP request and continue to stream your data under the same request. No need for the web sockets layer.

xtianus79

comment created time in 2 hours

PR closed HenningM/express-ws

Bump `ws`

This change is our reason for forking: bumping ws to the latest version.

The primary purpose for this is that older versions of ws have a bug where they don't emit a 'close' event properly on closing.

However, we also should use the latest version for security reasons.

+101 -2

0 comment

6 changed files

alecgibson

pr closed time in 7 days

PR opened HenningM/express-ws

Bump `ws`

This change is our reason for forking: bumping ws to the latest version.

The primary purpose for this is that older versions of ws have a bug where they don't emit a 'close' event properly on closing.

However, we also should use the latest version for security reasons.

+101 -2

0 comment

6 changed files

pr created time in 7 days

startedjoepie91/python-whois

started time in 7 days

startedjoepie91/python-whois

started time in 8 days

issue closedtc39/proposal-optional-chaining

Typo (missing the dot operator)

https://github.com/tc39/proposal-optional-chaining/blob/8461024a040d9c41ec039e2d4291fe2dfda36574/README.md#L58

The following constructs are missing the dot . operator: a?[b] or a?(b)

It should be: a?.[b] or a?.(b)

closed time in 8 days

RinatValiullov

issue commenttc39/proposal-optional-chaining

Typo (missing the dot operator)

No, because this sentence refers to the languages mentioned in the “Prior Art” section, not to ECMAScript.

RinatValiullov

comment created time in 8 days

issue openedtc39/proposal-optional-chaining

Typo (missing the dot operator)

https://github.com/tc39/proposal-optional-chaining/blob/8461024a040d9c41ec039e2d4291fe2dfda36574/README.md#L58

The following constructs are missing the dot . operator: a?[b] or a?(b)

It should be: a?.[b] or a?.(b)

created time in 8 days

startedjoepie91/node-random-number-csprng

started time in 9 days

startedjoepie91/node-random-number-csprng

started time in 9 days

startedjoepie91/node-random-number-csprng

started time in 9 days

startedjoepie91/node-random-number-csprng

started time in 9 days

startedjoepie91/node-random-number-csprng

started time in 9 days

fork xsgwork/python-whois

A python module for retrieving and parsing WHOIS data

fork in 16 days

starteddai-shi/reactive-react-redux

started time in 17 days

issue closedHenningM/express-ws

How can I stop getting ECONNRESET errors when closing Express-WS socket?

I'm using express-ws to add Websocket endpoints to my web app and am coding a test echo client from a browser. No matter how I close the connection, I get 2 socket errors on the server side, and I'd like to figure out a way to properly close the connections even if I have to bypass the framework and handle the net.socket manually. All pages about using Websockets say "call close()". Here is my code:

Server

app.ws(conf.routeNames.main, function (ws, req) {
  ws.on('message', function (msg) {
    wslog.info(msg);
    ws.send(msg);
  });
  ws.on('close', function(reason, desc) {
    wslog.info(`${reason} closed connection (${desc})`);
    ws.close();
  })
  ws.on('error', (err)=>{
    wslog.info(`ws-error ${err}`);
  });
});

Also on server:

  function onConnection (socket) {
    reqsPerSocket.set(socket, 0)
    socket.once('close', () => reqsPerSocket.delete(socket))
    socket.on('error', function(e){
      wslog.error(`Inbound connection error: ${e.message} from ${socket.remoteAddress}`);
    })
  }

Client

/*
 * ws-client.js
 *
 * Provides a barebones websocket client.
 * 
 */

wsClient = (function ($) {

  var ws; 
  var clientID;
  var tripCounter = 0;
  var clientLog;
  var mint;

  var wsURL = 'wss://{envHost}/wsecho/';

  function wsClient(h,a,c) {

    clientLog = c;
    clientID = a;

    wURL = wsURL.replace(/{envHost}/, h);
    ws = new WebSocket(wURL);

    ws.onopen = onOpen;
    ws.onmessage = onMessage;
    ws.onclose = onClose;
    ws.onerror = onError;

    window.addEventListener('beforeunload', imDoneWitDisGuy);
  }

  function onError(err) {
    clientLog.log(clientID +': '+err.message);
  }

  function onMessage(event) {
    clientLog.log(event.data);
    tripCounter++;
  }

  function onOpen() {
    clientLog.log('OnOpen - sending '+tripCounter);
    ws.send(clientID + ' ' + tripCounter );

    // This is where we ping server.
    mint = setInterval( function () {
      if( ws.readyState == 1 ) {
        clientLog.log('Sending '+tripCounter );
        ws.send(clientID +' '+tripCounter);
      }
    },60000);
  }

  function imDoneWitDisGuy() {
    clientLog.log('Window closing.');
    clearInterval(mint);
    if( ws.readyState == 1 ) {
      ws.close(1000, clientID + ' Window closing.');
    }
  }

  function onClose(event) {
    clientLog.log('Closing socket after ' + tripCounter + ' messages ' + (event.reason?'reason = '+event.reason:''));
    clearInterval(mint);
  }
  
  return wsClient; 
  
})(jQuery);

And here is the output I get on both sides: Client log:

2020-11-11T10:44:05.655 -05:00: OnOpen - sending 0
2020-11-11T10:44:05.854 -05:00: 88771 0
2020-11-11T10:44:26.829 -05:00: Window closing.
2020-11-11T10:44:26.871 -05:00: Closing socket after 1 messages reason = 88771 Window closing.

Server log:

2020-11-11T10:44:05-05:00 info: 88771 0
2020-11-11T10:44:26-05:00 error: Inbound connection error: read ECONNRESET from undefined
2020-11-11T10:44:26-05:00 error: Inbound connection error: read ECONNRESET from undefined
2020-11-11T10:44:26-05:00 info: 1000 closed connection (88771 Window closing.)

How can I stop getting ECONNRESET errors?

closed time in 22 days

ChrisMiami

issue commentHenningM/express-ws

How can I stop getting ECONNRESET errors when closing Express-WS socket?

My node app is deployed behind an IIS Reverse Proxy and when I connect directly to the app, the connection is closed cleanly. When behind the IIS Reverse Proxy, IIS must be intercepting the close event and not allowing a clean disconnect. The problem, therefore, must lie within IIS.

ChrisMiami

comment created time in 22 days

issue openedHenningM/express-ws

How can I stop getting ECONNRESET errors when closing Express-WS socket?

I'm using express-ws to add Websocket endpoints to my web app and am coding a test echo client from a browser. No matter how I close the connection, I get 2 socket errors on the server side, and I'd like to figure out a way to properly close the connections even if I have to bypass the framework and handle the net.socket manually. All pages about using Websockets say "call close()". Here is my code:

Server

app.ws(conf.routeNames.main, function (ws, req) {
  ws.on('message', function (msg) {
    wslog.info(msg);
    ws.send(msg);
  });
  ws.on('close', function(reason, desc) {
    wslog.info(`${reason} closed connection (${desc})`);
    ws.close();
  })
  ws.on('error', (err)=>{
    wslog.info(`ws-error ${err}`);
  });
});

Also on server:

  function onConnection (socket) {
    reqsPerSocket.set(socket, 0)
    socket.once('close', () => reqsPerSocket.delete(socket))
    socket.on('error', function(e){
      wslog.error(`Inbound connection error: ${e.message} from ${socket.remoteAddress}`);
    })
  }

Client

/*
 * ws-client.js
 *
 * Provides a barebones websocket client.
 * 
 */

wsClient = (function ($) {

  var ws; 
  var clientID;
  var tripCounter = 0;
  var clientLog;
  var mint;

  var wsURL = 'wss://{envHost}/wsecho/';

  function wsClient(h,a,c) {

    clientLog = c;
    clientID = a;

    wURL = wsURL.replace(/{envHost}/, h);
    ws = new WebSocket(wURL);

    ws.onopen = onOpen;
    ws.onmessage = onMessage;
    ws.onclose = onClose;
    ws.onerror = onError;

    window.addEventListener('beforeunload', imDoneWitDisGuy);
  }

  function onError(err) {
    clientLog.log(clientID +': '+err.message);
  }

  function onMessage(event) {
    clientLog.log(event.data);
    tripCounter++;
  }

  function onOpen() {
    clientLog.log('OnOpen - sending '+tripCounter);
    ws.send(clientID + ' ' + tripCounter );

    // This is where we ping server.
    mint = setInterval( function () {
      if( ws.readyState == 1 ) {
        clientLog.log('Sending '+tripCounter );
        ws.send(clientID +' '+tripCounter);
      }
    },60000);
  }

  function imDoneWitDisGuy() {
    clientLog.log('Window closing.');
    clearInterval(mint);
    if( ws.readyState == 1 ) {
      ws.close(1000, clientID + ' Window closing.');
    }
  }

  function onClose(event) {
    clientLog.log('Closing socket after ' + tripCounter + ' messages ' + (event.reason?'reason = '+event.reason:''));
    clearInterval(mint);
  }
  
  return wsClient; 
  
})(jQuery);

And here is the output I get on both sides: Client log:

2020-11-11T10:44:05.655 -05:00: OnOpen - sending 0
2020-11-11T10:44:05.854 -05:00: 88771 0
2020-11-11T10:44:26.829 -05:00: Window closing.
2020-11-11T10:44:26.871 -05:00: Closing socket after 1 messages reason = 88771 Window closing.

Server log:

2020-11-11T10:44:05-05:00 info: 88771 0
2020-11-11T10:44:26-05:00 error: Inbound connection error: read ECONNRESET from undefined
2020-11-11T10:44:26-05:00 error: Inbound connection error: read ECONNRESET from undefined
2020-11-11T10:44:26-05:00 info: 1000 closed connection (88771 Window closing.)

How can I stop getting ECONNRESET errors?

created time in 22 days

issue openedHenningM/express-ws

How can i make broadcast with express-ws ?

In the documentation is writed that with getWss() we can get all clients. But it is not explained how. From the method i get a long object, and i don't know how can i make broadcasting, so messege is send to all clients that are connected to my websocket.

Also in the documentation for -- wsInstance.getWss() --is written:

Note that this list will include all clients, not just those for a specific route - this means that it's often not a good idea to use this for broadcasts, for example.

But the getWss() method is the only one that is pointed to some broadcasting. If it is not good idea then what should we use ?

created time in 23 days

issue openedjoepie91/python-whois

Catastrophic backtracking on '.fr' domains

Hello!

While I understand this project may no longer be maintained (based on the latest commit being over six years old, etc.), because of the potentiaI for this issue to negatively affect production applications, I figured I'd create this to bring attention to / warn others it might impact

Description:

At some point in the course of parsing a WHOIS record (provided by the AFNIC WHOIS server) associated with a french domain (using the '.fr' TLD), it appears the library attempts to match the entire record string against this regular expression:

/nic-hdl:\s*(?P<handle>.+)\ntype:\s*(?P<type>.+)\ncontact:\s*(?P<name>.+)\n(?:.+\n)*?(?:address:\s*(?P<street1>.+)\n)?(?:address:\s*(?P<street2>.+)\n)?(?:address:\s*(?P<street3>.+)\n)?(?:phone:\s*(?P<phone>.+)\n)?(?:fax-no:\s*(?P<fax>.+)\n)?(?:.+\n)*?(?:e-mail:\s*(?P<email>.+)\n)?(?:.+\n)*?changed:\s*(?P<changedate>[0-9]{2}\/[0-9]{2}\/[0-9]{4}).*/

I think it's this one: https://github.com/joepie91/python-whois/blob/7b0ddf755b3d706860d5d8cb80c598fd854a48ca/pythonwhois/parse.py#L376

This evaluation results in catastrophic backtracking and never recovers, causing the application to hang and CPU usage to increase dramatically. Off hand -- records provided by AFNIC seem to have multiple repeated fields like 'ADDRESS' and 'TROUBLE', so it's possible that's where the evaluation is getting tripped up.

Reproduction Steps:

  1. Clone the repository, or install the package via pip. I used virtualenv and created a sample environment to test this in. I'm also using python 2.7.10.

  2. Use the included pwhois script (or a provided method like pythonwhois.get_whois(domain)) to run the lookup against a .fr domain like 'afnic.fr', e.g. pwhois afnic.fr. The process should hang and CPU usage should rapidly increase. I can provide a proof of concept via an online regular expression evaluator if that would be helpful!

If this description is at all unclear or if you would like me to provide additional information, just let me know!

Thanks!

created time in 24 days

startedLoicMahieu/react-styled-flexboxgrid

started time in 24 days

startedjotfs/jotfs

started time in a month

startedgoogle/schemarama

started time in a month

startedpmndrs/jotai

started time in a month

fork justincampagna1/zippydoc

Documentation markup language and library, including HTML converter.

fork in a month

fork justincampagna1/python-whois

A python module for retrieving and parsing WHOIS data

fork in a month

push eventrevspace/co2sensor

Bertrik Sikken

commit sha bcda9a8fcf204e79238a1432679a23728673adf0

Make libraries more explicit by adding author in platformio configuration.

view details

push time in a month

starteddai-shi/proxy-memoize

started time in a month

startedvpaladino778/SpotifyPlaylistAnalysis

started time in a month

startednfriend/ts-key-enum

started time in a month

more