Transaction ID error in Windows server 2008

Help
GengWang
2012-08-02
2013-05-28
  • GengWang
    GengWang
    2012-08-02

    Hi, I have a modbus application using jamod.jar which runs OK in windows 2003. But when this application is running in Windows 2008. It fails to work correctly. The problem is that if a read operation is done and a write operation follows, getResponse() from slave is from the previous read operation instead of the current write operation so we can not cast the Response to ReadInputRegistersResponse.
    After the error happens, getRequest() returns the write request by the first 2 bytes which is the transaction ID is wrong. This wrong transactionID Increases with number of transactions.
    I can add a re try to the write operation and it will succeed. But after a few hours of running, the re try will finally fail with transaction ID to be over 60000.
    This error only happens in Windows server 2008.
    Can anyone help to indicate what is wrong?

    Thanks.

    Geng

     
  • Julie Haugh
    Julie Haugh
    2012-08-06

    Receive your response as a ModbusResponse, then get the transaction ID from the response and check.  If they don't match, discard the response and try again.

    The fix is in ModbusTCPTransaction.execute().  A do-while loop needs to be added with the loop termination condition being either matching transaction IDs or some form of timeout.