WIZnet Developer Forum

WIZ550S2E-485 Modbus TCP Server - connection reset by peer

Hello,
I’m trying to see if it’s possible to configure a WIZ550S2E-485 EV as a Modbus TCP to RTU gateway.

Now I’m trying to send a modbus request through the lib modbus, but then nothing is sent on the RS485 side, and I receive a Connection Reset By Peer error.
This is the shortest C program that trigger the error (I’m omitting error checking for brevity).

#include <modbus/modbus-tcp.h>

int main(int argc, char** argv) {
uint16_t buf[256];
modbus_t *ctx;

ctx = modbus_new_tcp("192.168.11.100", 5000);
modbus_set_debug(ctx, TRUE);
modbus_set_slave(ctx, 2);
modbus_connect(ctx);

modbus_read_registers(ctx, 1, 1, buf);

modbus_close(ctx);
modbus_free(ctx);

return 0;

}

Output:
$ ./mdb_test
Connecting to 192.168.11.100:5000
[00][01][00][00][00][06][02][03][00][01][00][01]
Waiting for a confirmation…
ERROR Connection reset by peer: read

With Wireshark I noticed a Malformed Packet Error, but I don’t know if it’s the cause. (I can’t include a screenshot because new users are allowed to send only one image)

I can’t figure out if there is something wrong on the configuration, on the C program or on the expectations.

Thank you,
Emanuele

Hello Emanuele,

Please refer to our Modbus library of WIZ550S2E code.
You can see this through below link.

I tested modbus function of WIZ550S2E through modbus poll and modbus slave
It was no problem.

Thank you.

Hi Mason,
I tried to configure with Configuration Tool 1.20, but the result didn’t change. I was previously using v 1.31.

With Modbus Poll the result is “Read Error”:

A capture with Wireshark gives this result:

connection_reset.pcapng.zip (200,0 KB)

that however I’m not able to understand.

No idea of what could go wrong?

Hi Mason, I’m working on the same project as Emanuele.

We don’t understand why the WIX550 is resetting the communication.

As you see we tested the Master you suggested (Modbus Poll) and also another Master we’re using successfully with a different adapter (Moxa Modbus Gateway MGate MBxxxx).

Probably there is a configuration that we overlooked. Is there any difference we should consider while moving from Moxa to WIX?

Thank you for your attention,

  Ezio

Hi again,

We did some progress, doing multiple testing, we found out there is a critical timing between the connection and the sending of the first Modbus request.

  • If we send the request right after the connection, we get the “malformed packet”

  • If we connect, and do nothing afterwards, the WIZ keeps the connection alive for 5", and then disconnects

  • If we connect, wait 1" and send a Modbus request, Wiz disconnects right after the request
    The Modbus request is well formed, we sniffed it with Wireshark

We keep track of connection/disconnection by looking at the green LED.

Is this the expected behavior? I would say no, since Wiz is a Modbus slave (AKA Server) and therefore it’s connection must be kept alive forever and listening for incoming requests.

Maybe we have to configure some timeout/keepalive parameter?

Thank you again for your attention,

        Ezio

Problem solved!
Connection password must be empty.

Thank you for your help!

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.