Below is link:
Below is the disconnect after release:
Below is the reconnection error:
Transferred to the source code below, find here again before connecting the port, the dispose method does not release the local port
CodePudding user response:
If possible best to nettyhttps://camel.apache.org/components/2.x/mina2-component.html
One tip: Favor using Netty as Netty is a much more active maintained and popular project than Apache Mina currently is
Support the use of Netty because Netty is a more active than Apache Mina current, preferred project
CodePudding user response:
Check the API documentation, the dispose will not necessarily free port, may be blockedhttp://mina.apache.org/mina-project/gen-docs/2.0.20/apidocs/org/apache/mina/transport/socket/nio/NioDatagramConnector.html
Public final void the dispose ()
Releases any resources allocated by this service. Do note that this method took block as long as there are any sessions managed by this service.
Specified by:
The dispose in interface IoService
So, you can use getManagedSessions () to close all the IoSession closeNow (call () method), and then to the dispose
GetManagedSessions reference
http://mina.apache.org/mina-project/gen-docs/2.0.20/apidocs/org/apache/mina/core/service/IoService.html#getManagedSessions -
CloseNow reference
http://mina.apache.org/mina-project/gen-docs/2.0.20/apidocs/org/apache/mina/core/session/IoSession.html#closeNow -