[
https://issues.apache.org/jira/browse/THRIFT-4246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16108406#comment-16108406
]
ASF GitHub Bot commented on THRIFT-4246:
----------------------------------------
GitHub user boivie opened a pull request:
https://github.com/apache/thrift/pull/1322
THRIFT-4246 Multiplexed clients sequence id fix
Client: nodejs
Previously, all clients would use the latest created multiplexer
for generating sequence numbers which would create a mismatch
between the mapping of sequence number->service in the connection.
This makes the client instances use the multiplexer that is
bound to it.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/boivie/thrift seq-id-mismatch
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/1322.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 #1322
----
commit 91369aebfc5ca910cdd3871ee59de7a1e8244b6f
Author: Victor Boivie <[email protected]>
Date: 2017-07-08T11:21:55Z
THRIFT-4246 Multiplexed clients sequence id fix
Client: nodejs
Previously, all clients would use the latest created multiplexer
for generating sequence numbers which would create a mismatch
between the mapping of sequence number->service in the connection.
This makes the client instances use the multiplexer that is
bound to it.
----
> Sequence number mismatch on multiplexed clients
> -----------------------------------------------
>
> Key: THRIFT-4246
> URL: https://issues.apache.org/jira/browse/THRIFT-4246
> Project: Thrift
> Issue Type: Bug
> Components: Node.js - Library
> Affects Versions: 0.10.0
> Reporter: Victor Boivie
> Priority: Critical
> Attachments:
> 0001-THRIFT-4246-Multiplexed-clients-sequence-id-fix.patch
>
>
> When performing calls using a multiplexed client and when having multiple
> connections and clients, the wrong sequence numbers are used which will often
> result in responses not being able to be delivered to the client. This is
> because every connection will make the client class (not instance) use the
> latest created multiplexer class to generate sequence numbers. The following
> example shows the problem:
> {code:javascript}
> const thrift = require('thrift');
> const AlphaService = require('./gen-nodejs/AlphaService');
> const BetaService = require('./gen-nodejs/BetaService');
> let connection1 = thrift.createConnection('localhost', 9091, {
> transport: thrift.TFrameTransport,
> protocol: thrift.TCompactProtocol,
> });
> let multiplexer1 = new thrift.Multiplexer();
> let alpha1 = multiplexer1.createClient('alpha', AlphaService, connection1);
> let beta1 = multiplexer1.createClient('beta', BetaService, connection1);
> alpha1.echoAlpha("hello")
> let connection2 = thrift.createConnection('localhost', 9091, {
> transport: thrift.TFrameTransport,
> protocol: thrift.TCompactProtocol,
> });
> let multiplexer2 = new thrift.Multiplexer();
> let alpha2 = multiplexer2.createClient('alpha', AlphaService, connection2);
> let beta2 = multiplexer2.createClient('beta', BetaService, connection2);
> beta1.echoBeta("Hi")
> beta2.echoBeta("hello")
> console.log("alpha1 seqId", alpha1._seqid)
> console.log("beta1 seqId", beta1._seqid)
> console.log("beta2 seqId", beta2._seqid)
> console.log("multiplexer1 latest", multiplexer1.seqid)
> console.log("multiplexer2 latest", multiplexer2.seqid)
> console.log("connection1 mapping", connection1.seqId2Service)
> console.log("connection2 mapping", connection2.seqId2Service)
> {code}
> Result:
> {noformat}
> alpha1 seqId 1
> beta1 seqId 1
> beta2 seqId 2
> multiplexer1 latest 1
> multiplexer2 latest 2
> connection1 mapping { '1': 'beta' }
> connection2 mapping { '2': 'beta' }
> {noformat}
> Connection1 should have mapping 1 -> alpha, 2-> beta
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)