plc4x icon indicating copy to clipboard operation
plc4x copied to clipboard

[Bug]: The onError calls are always ignored

Open splatch opened this issue 1 year ago • 1 comments

What happened?

Any send operation which expects response can specify criteria for matching answers but also error handlers which should be called when handling logic fails. Determination when error handler should be called is not trivial. Most of protocols have fairly long unwrap/check statements which can fail at any stage. We can not assume which stage will fail, we can't layer error handlers, thus we need carefully craft logic and make sure that we don't catch too much and still propagate failures to driver and clean up handlers. Currently it might be that packet consumers are retained until timeout, even if we know that they can't properly handle incoming data.

Version

v0.12

Programming Languages

  • [X] plc4j
  • [ ] plc4go
  • [ ] plc4c
  • [ ] plc4net

Protocols

  • [ ] AB-Ethernet
  • [ ] ADS /AMS
  • [ ] BACnet/IP
  • [ ] CANopen
  • [ ] DeltaV
  • [ ] DF1
  • [ ] EtherNet/IP
  • [ ] Firmata
  • [ ] KNXnet/IP
  • [ ] Modbus
  • [ ] OPC-UA
  • [ ] S7

splatch avatar Aug 13 '24 10:08 splatch

I noticed while tracking down some issues in the EIP when connecting to my WAGO device, that also errors thrown in the handlers don't seem to arive at the user ... so I changed:

throw new PlcRuntimeException("The remote device doesn't seem to use " + configuration.getByteOrder().name() + " byte order.");

To:

context.getChannel().pipeline().fireExceptionCaught(new PlcRuntimeException("The remote device doesn't seem to use " + configuration.getByteOrder().name() + " byte order."));

And now I'm getting the errors, I was expecting to see.

chrisdutz avatar Aug 16 '24 13:08 chrisdutz