how to Pass tls.CleartextStream instance to worker process

86 views
Skip to first unread message

chenxu zhao

unread,
May 21, 2013, 7:07:58 AM5/21/13
to nod...@googlegroups.com
 i have the same problem like this post 


I want to use a stream.pipe to send.

but how, like this ?

var  tls_socket = new net.sockert()
cleartextStream.pipe(tls_socket);

but tls_socket can't send to child_process too .

child_process.js:134
      handle.onread = function() {};
                    ^
TypeError: Cannot set property 'onread' of null
    at ChildProcess.handleConversion.net.Socket.send (child_process.js:134:21)
    at ChildProcess.target.send (child_process.js:436:52)
    at Server.<anonymous> (/Users/zcx/BestApp/android-mqtt-push-server/server_master_zmq.js:171:12)
    at Server.EventEmitter.emit (events.js:98:17)
    at SecurePair.<anonymous> (tls.js:1117:16)
    at SecurePair.g (events.js:175:14)
    at SecurePair.EventEmitter.emit (events.js:92:17)
    at SecurePair.maybeInitFinished (tls.js:896:10)
    at CleartextStream.read [as _read] (tls.js:430:15)
    at CleartextStream.Readable.read (_stream_readable.js:294:10)


Ben Noordhuis

unread,
May 21, 2013, 7:40:48 AM5/21/13
to nod...@googlegroups.com
You cannot send over tls objects. They're tied to OpenSSL SSL_CTX
objects and those are not transferable to other processes.

You can however send net.Socket objects and do something like below in
your workers:

var server = tls.createServer(...);
process.on('message', function(msg, handle) {
assert(handle instanceof net.Socket);
server.emit('connection', handle);
});

As long as you send over the net.Socket objects before the SSL/TLS
handshake has begun, this should work fine.

chenxu zhao

unread,
May 21, 2013, 8:44:22 AM5/21/13
to nod...@googlegroups.com
yes, I know I can't send  OpenSSL SSL_CTX object.

so I want to use the stream.pipe to send a socket object. becase the only socket and 

but I don't konw how to implemate 。


--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Reply all
Reply to author
Forward
0 new messages