node-modbus-serial: Server is not processing parallel requests

I just started the example server

I created a client that sends more three readHoldingRegisters requests.

However, on the server, some requests are not being received. This is not an issue with the client as I have tested it with a simulator and it works fine.

I’ve just put multiple requests in the example client logger.

function run() {

    // read the 4 registers starting at address 5
    client.readHoldingRegisters(5, 4)
        .then(function(d) {
            console.log("Receive:", d.data); })
        .then(function() {
        	setTimeout(run, 1000); })
        .catch(function(e) {
            checkError(e);
            console.log(e.message); });
            
     client.readHoldingRegisters(10, 4)
        .then(function(d) {
            console.log("Receive:", d.data); })
        .catch(function(e) {
            checkError(e);
            console.log(e.message); });
     client.readHoldingRegisters(15, 4)
        .then(function(d) {
            console.log("Receive:", d.data); })
        .catch(function(e) {
            checkError(e);
            console.log(e.message); });
}

On the server, the getHoldingRegister does not get executed for all of the addresses.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (12 by maintainers)

Most upvoted comments

I found the same issue while working for another PR. I will try to release the fix for this one too.

I am really sorry for the long weekend

Never be sorry for a long weekend 😃

Hi, Sorry just saw the thread. I’ll test it today and see if its working in my case

@pkaz can you try the same example after applying my PR? https://github.com/yaacov/node-modbus-serial/pull/216

Wait, I forgot that PDU won’t be always of 8 bytes, we should read the message length field inside the MBAP and act accordingly. So, why is the check inside _errorRequestBufferLength() forcing a length of 8 bytes?