I was looking at this thread Secure random token in Node.js and tried to make a function:
var crypto = require('crypto');
function token() { // create a secure token
var token;
crypto.randomBytes(48, function(ex, buf) {
token = buf.toString('hex');
});
return token;
}
// more code...
var token = token();
It crashes:
Error: read ECONNRESET
at exports._errnoException (util.js:746:11)
at TCP.onread (net.js:559:26)
Any reasons to why?
"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one or more application protocol errors. You could look at the API server logs to see if it complains about something.