Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Costas Zarifis


Tutorials, code snippets, hacks and more...

Socket.io Random Number Generator Error

Socket.io Image

So, if you decide to use socket.io in one of your projects, you might come accross the following error:

ERROR [karma]: [Error: error:24064064:random number generator:SSLEAY_RAND_BYTES:PRNG not seeded]

followed by a long and scary stack traceback. Not to worry there's a fix for that!

Open the file:

node_modules/karma/node_modules/socket.io/lib/manager.js

Go to line 734 (it might actually be a couple of lines above or below that, look around!) and replace the following snippet:

if (crypto.randomBytes) {
    crypto.randomBytes(12).copy(rand);
} else { ....

with this:

if (crypto.pseudoRandomBytes) {
    crypto.pseudoRandomBytes(12).copy(rand);
} else {

That's it! It should be good to go now!


About the author

Costas Zarifis


Discussions

comments powered by Disqus