Victor Boivie created THRIFT-4246:
-------------------------------------

             Summary: 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


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)

Reply via email to