GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Inbound data lost when TLS connection resets. · Issue #149 · nodejs/node

Inbound data lost when TLS connection resets. #149

New issue
Copy link
New issue
Copy link
Closed
Closed
Inbound data lost when TLS connection resets.#149
Copy link

Description

@argon
argon
opened on Dec 11, 2014
Issue body actions

Duplicate of nodejs/node-v0.x-archive#8299

I am connecting to a remote server with a TLS connection, writing large amounts of data. When an error occurs the remote server writes one packet of data giving details of the error then immediately terminates the connection by sending RST.

The issue I have found is that if the remote server detects an error and closes the connection while my application is in the process of sending data, the connection will emit an EPIPE error on syscall "write" and immediately destroy the connection. Because the connection is destroyed, the data that is sent by the server is never read by node.js running the application and is simply lost.

I have discovered the following workaround which is far from ideal as it messes around with the internal machinery of node sockets, but works for me.

function destroyEPIPEFix(e) {
    // When a write error occurs we miss the opportunity to
    // read error data from the remote server. Delay the call to destroy
    // to allow more data to be read.
    var self = this;
    var args = arguments;
    var call = function () {
        self._myDestroy.apply(self, args); 
    }

    if (e && e.syscall == "write") {
        setTimeout(call, 1000);
    }
    else {
        call();
    }
}


socket = tls.connect([...]);
socket._myDestroy = socket._destroy;
socket._destroy = destroyEPIPEFix;

When I setup the connection I replace the _destroy method with one of my own making that delays the actual call to destroy by 1second when a write error occurs. 1second is actually much longer than it needs to be, but I am prepared to sacrifice the time to ensure the data is received.

Without the fix data is sometimes lost when a disconnection occurs, though not always. With the fix in place I have yet to lose any data, so the method is sound, but the implementation could use some work.

Unfortunately I have not been able to create a reliable test case so far. I have only observed the problem with a TLS connection but I would imagine it is a general TCP socket problem with node.

Activity

  1. chrisdickinson commented on Jan 18, 2015

    @chrisdickinson
    chrisdickinson
    on Jan 18, 2015
    Contributor
    More actions

    Closing this – going to try and keep bugs that pertain to both joyent/node and iojs on the tracker they originate from!

  2. chrisdickinson
    closed this as completedon Jan 18, 2015
  3. boingoing
    added a commit that references this issue on Apr 6, 2017

    Merge pull request nodejs#149 from boingoing/fix_test_function

    ad4c813
  4. nodejs-github-bot commented on Mar 7, 2020

    @nodejs-github-bot
    nodejs-github-bot
    on Mar 7, 2020
    Collaborator
    More actions

    CI: https://ci.nodejs.org/job/node-test-pull-request/29596/

  5. nodejs-github-bot commented on Mar 8, 2020

    @nodejs-github-bot
    nodejs-github-bot
    on Mar 8, 2020
    Collaborator
    More actions

    CI: https://ci.nodejs.org/job/node-test-pull-request/29638/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.