QModbusServer on Raspberry Pi: Connection Refused by Server
Solved
QtonPi
-
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.