[ https://issues.apache.org/jira/browse/THRIFT-3786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15235614#comment-15235614 ]
ASF GitHub Bot commented on THRIFT-3786: ---------------------------------------- GitHub user jamesreggio opened a pull request: https://github.com/apache/thrift/pull/985 THRIFT-3786 Fix premature firing of `connect` event for secure sockets `tls.connect()` returns a socket that will fire a `connect` event when the initial socket is connected, followed by a `secureConnect` event when the TLS handshake is complete This commit causes the Thrift connection to wait until `secureConnect` to broadcast its own `connect` event and begin using the secure socket. This helps to resolve a race condition where commands issued after `connect` but before `secureConnect` are lost. It also fixes loss of commands in the offline queue, as well as double-broadcasting due to the same handler running on both underlying `connect` events. You can merge this pull request into a Git repository by running: $ git pull https://github.com/jamesreggio/thrift THRIFT-3786 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/985.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #985 ---- commit b76bad70826d539ddfb26b5277ff3bc09ffa9803 Author: James Reggio <james.reg...@gmail.com> Date: 2016-04-11T17:53:12Z THRIFT-3786 Fix premature firing of `connect` event for secure sockets tls.connect() returns a socket that will fire a `connect` event when the initial socket is connected, followed by a `secureConnect` event when the TLS handshake is complete This commit causes the Thrift connection to wait until `secureConnect` to broadcast its own `connect` event and begin using the secure socket. This helps to resolve a race condition where commands issued after `connect` but before `secureConnect` are lost. It also fixes loss of commands in the offline queue, as well as double-broadcasting due to the same handler running on both underlying `connect` events. ---- > Node.js TLS emits 'connect' before connection is ready > ------------------------------------------------------ > > Key: THRIFT-3786 > URL: https://issues.apache.org/jira/browse/THRIFT-3786 > Project: Thrift > Issue Type: Bug > Components: Node.js - Library > Reporter: James Reggio > > When using a TLS connection, the Node.js Thrift connection instance will emit > a `connect` event early, making it possible to lose commands. > `connect` is emitted by the Thrift connection instance when the underlying > socket is opened, instead of when the TLS handshake has completed. Making > matters worse, the offline queue is flushed during this premature `connect`, > which means that any commands issued prior to the TLS connection handshake > will be lost. -- This message was sent by Atlassian JIRA (v6.3.4#6332)