Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QModbusServer on Raspberry Pi: Connection Refused by Server



  • Hi,
    I have created QModbusServer (TCP) in my application on windows 10 laptop.
    Following code is for create tcp modbus server.

    const QUrl url = QUrl::fromUserInput("127.0.0.1:1502");
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkAddressParameter, url.host());```
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkPortParameter, url.port());
    modbusDevice->setServerAddress(1);
    

    Server is running well. I can connect my LabVIEW Modbus Client application from same Laptop.
    Now I started server application on raspberry pi.
    During connect request from laptop, LabVIEW modbus client shows following error.

    LabVIEW: Serial buffer overflow, Connection refused by server & terminated.
    


  • I changed code as following, now working fine.

    //const QUrl url = QUrl::fromUserInput("127.0.0.1:1502");
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkAddressParameter, "localhost");
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkPortParameter, 1502);
    modbusDevice->setServerAddress(1);
    

    "127.0.0.1" is loopback address, which refuses remote connection.



  • I changed code as following, now working fine.

    //const QUrl url = QUrl::fromUserInput("127.0.0.1:1502");
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkAddressParameter, "localhost");
    modbusDevice->setConnectionParameter(QModbusDevice::NetworkPortParameter, 1502);
    modbusDevice->setServerAddress(1);
    

    "127.0.0.1" is loopback address, which refuses remote connection.


Log in to reply