Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: modbus over serial port(com) could not closed successfully. #1610

Open
2 of 16 tasks
liudianwei opened this issue May 23, 2024 · 5 comments
Open
2 of 16 tasks

[Bug]: modbus over serial port(com) could not closed successfully. #1610

liudianwei opened this issue May 23, 2024 · 5 comments
Assignees
Labels
bug java Pull requests that update Java code Modbus https://plc4x.apache.org/users/protocols/modbus.html

Comments

@liudianwei
Copy link

What happened?

modbus over serial port(com) could not closed successfully, try to call PlcConnection.close() when com disconnect, it will be in an endless loop. the major reason is that it will call channel close by netty automatically when shutdown NioEventLoop, and serial channel will put an doClose in eventLoop, it will call close again because eventLoopUp is not empty, and than, trapped in a dead cycle...
temp solution:
close method should only support call once.
image
image
image
file location plc4x\plc4j\transports\serial\src\main\java\org\apache\plc4x\java\transport\serial

Version

latest

Programming Languages

  • plc4j
  • plc4go
  • plc4c
  • plc4net

Protocols

  • AB-Ethernet
  • ADS /AMS
  • BACnet/IP
  • CANopen
  • DeltaV
  • DF1
  • EtherNet/IP
  • Firmata
  • KNXnet/IP
  • Modbus
  • OPC-UA
  • S7
@liudianwei liudianwei added the bug label May 23, 2024
@liudianwei
Copy link
Author

link #1342

@liudianwei
Copy link
Author

link #1212

@chrisdutz chrisdutz self-assigned this May 24, 2024
@ottlukas ottlukas added java Pull requests that update Java code Modbus https://plc4x.apache.org/users/protocols/modbus.html labels Jul 5, 2024
@chrisdutz
Copy link
Contributor

As one of the issues you referenced is closed as "works now" could you please re-test if the problem still exists?

@chrisdutz chrisdutz added the awaiting-feedback This label is applied when an issue has been opened and we need more information from the issuer. label Aug 2, 2024
@liudianwei
Copy link
Author

still exists.

@chrisdutz chrisdutz removed the awaiting-feedback This label is applied when an issue has been opened and we need more information from the issuer. label Aug 16, 2024
@oliviercoma
Copy link

We're also impacted by this issue.
I wanted to work on a fix, but the SerialChannel implementation seems really hacky without much information / comments and thus really difficult to work on:

  • Why close method from AbstractChannel.AbstractUnsafe is overriden and completely by-passed as it deals with the specific issue (variable closeInitiated)
  • Why unsafe() returns a new instance each time (a new instance is recreated at each read). Other implementations do not do that and only newUnsafe() is overriden. As newUnsafe() is not overriden, there is a rogue NioByteUnsafe that lies around.
  • Why SerialNioUnsafe.read() implementation is very similar (but a bit different) to the one from NioByteUnsafe. Why is it not overriden?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug java Pull requests that update Java code Modbus https://plc4x.apache.org/users/protocols/modbus.html
Projects
None yet
Development

No branches or pull requests

4 participants