redbird icon indicating copy to clipboard operation
redbird copied to clipboard

SSL Doesn't Work with Node 11

Open dacioromero opened this issue 5 years ago • 13 comments

I upgraded my server's Node 10 to 11 and started getting these errors while being completely unable to connect.

7|server   | le.challenges[tls-sni-01].loopback should be defined as function (opts, domain, token, keyAuthorization, cb) { ... } and should prove (by external means) that the ACME server challenge 'tls-sni-01' will succeed
7|server   | RangeError: Invalid typed array length: -4095
7|server   |     at new Uint8Array (<anonymous>)
7|server   |     at new FastBuffer (buffer.js:72:1)
7|server   |     at Handle.onStreamRead [as onread] (internal/stream_base_commons.js:144:17)
7|server   |     at Stream.<anonymous> (/srv/www/server/node_modules/handle-thing/lib/handle.js:88:10)
7|server   |     at Stream.emit (events.js:194:15)
7|server   |     at endReadableNT (/srv/www/server/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_readable.js:1038:12)
7|server   |     at args.(anonymous function) (/usr/lib/node_modules/pm2/node_modules/event-loop-inspector/index.js:138:29)
7|server   |     at process.internalTickCallback (internal/process/next_tick.js:72:19)

The first line is repeated multiple times and sometimes it would crash on RangeError.

server.js:

const path = require('path');

const proxy = require('redbird')({
    port: 80,
    letsencrypt: {
        path: path.join(__dirname, '/certs')
    },
    ssl: {
        http2: true,
        port: 443
    }
});

const sslSettings = {
    letsencrypt: {
        email: '[email protected]',
        production: true
    }
}

proxy.register('dacio.app', 'http://localhost:8080', {
    ssl: sslSettings
});

proxy.register('www.dacio.app', 'http://localhost:8080', {
    ssl: sslSettings
});

proxy.register('giphy.dacio.app', 'http://localhost:8081', {
    ssl: sslSettings
});

proxy.register('potatoes.dacio.app', 'http://localhost:8082', {
    ssl: sslSettings
});

proxy.register('teamlink.dacio.app', 'http://localhost:8083', {
    ssl: sslSettings
});

proxy.register('markov.dacio.app', 'http://localhost:8084', {
    ssl: sslSettings
});

proxy.register('unreddit.dacio.app', 'http://localhost:8085', {
    ssl: sslSettings
});

proxy.register('cohesion.dacio.app', 'http://localhost:8086', {
    ssl: sslSettings
});

dacioromero avatar Dec 12 '18 12:12 dacioromero

+1

balazsotakomaiya avatar Dec 28 '18 11:12 balazsotakomaiya

any solution?

snowdream avatar Jan 03 '19 10:01 snowdream

I get the same error

gtwilliams03 avatar Jan 24 '19 19:01 gtwilliams03

My error is slightly different - the proxy starts fine, but then throws an exception (in Node 11.8 - works fine in Node 10.15) when the first path is hit.

My proxy code:

var fs = require('fs-extra')

var proxyOptions = {
  port: 80, 
  ssl: { 
    port: 443,
    key: 'certs/mylocaldomain-key.pem',
    cert: 'certs/mylocaldomain-cert.pem',
    http2: true
  }
}

var proxy = require('redbird')(proxyOptions);
proxy.register("mylocaldomain.com", "http://localhost:3000/", { ssl: true });

// start the proxy server on the port specified above
function startServer(port){

  // just http for now, https in the future
  var http = require('http');

  function handleRequest(request, response){
    response.end('Path Hit: ' + request.url);
  }

  // run the server
  var server = http.createServer(handleRequest);
  server.listen(port, function(){
    console.log("Server listening on: http://localhost:%s", port);
  });
}

This starts fine. But when I hit a path - this error gets thrown, which is similar to the error mentioned by @DacioRomero above, but appears to be at a different place in the redbird code:

internal/buffer.js:788
class FastBuffer extends Uint8Array {}
^

RangeError: Invalid typed array length: -4095
    at new Uint8Array (<anonymous>)
    at new FastBuffer (internal/buffer.js:788:1)
    at Handle.onStreamRead [as onread] (internal/stream_base_commons.js:144:17)
    at Stream.<anonymous> (C:\Users\gtw\Documents\GitHub\severedlinks-react-app\node_modules\handle-thing\lib\handle.js:88:10)
    at Stream.emit (events.js:202:15)
    at endReadableNT (C:\Users\gtw\Documents\GitHub\severedlinks-react-app\node_modules\spdy-transport\node_modules\readable-stream\lib\_stream_readable.js:1047:12)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)

gtwilliams03 avatar Jan 29 '19 16:01 gtwilliams03

+1 Turning off HTTP/2 fixes it but I don't want to use HTTP/1.1

makidoll avatar Feb 06 '19 08:02 makidoll

With NodeJS 12 I get the same error when HTTP2 is turned on.

Any clues how to fix it or is anyone working on fix?

RangeError: Invalid typed array length: -4095 at new Uint8Array (<anonymous>) at new FastBuffer (internal/buffer.js:941:1) at Handle.onStreamRead [as onread] (internal/stream_base_commons.js:165:17) at Stream.<anonymous> (/node_modules/handle-thing/lib/handle.js:88:10) at Stream.emit (events.js:201:15) at endReadableNT (/node_modules/spdy-transport/node_modules/readable-stream/lib/_stream_readable.js:1077:12) at processTicksAndRejections (internal/process/task_queues.js:84:9)

mrkmrtns avatar May 17 '19 12:05 mrkmrtns

@mrkmrtns I've had to keep using nvm to rollback to node 10 in development. No idea how to fix this. I get the same error on every version of node above 10.

gtwilliams03 avatar Jun 01 '19 15:06 gtwilliams03

so there may be some breaking change in node 12 that breaks Redbird, I will take a look into it when I have some spare time, since the workaround is to use the current LTS version 10.

manast avatar Jun 02 '19 09:06 manast

This issue is still present with node 13.6.0. I really want to start using HTTP2, can this get fixed?

jojost1 avatar Jan 30 '20 19:01 jojost1

current LTS version 10

Node 12 is now in LTS. I have no problem using Node 10, but I can't test this as easily anymore now that I am using Docker and Traefik for my projects.

dacioromero avatar Jan 31 '20 05:01 dacioromero

Also stumbled upon this when I upgraded to 12. Is there really no way to fix it (other than http2 = false)?

chainria avatar Mar 11 '20 08:03 chainria

This issue is still present with node 14. I really want to start using HTTP2, can this get fixed?

RezaErfani67 avatar Mar 04 '21 13:03 RezaErfani67

I get the same error @manast ... please

RezaErfani67 avatar Mar 05 '21 10:03 RezaErfani67