Home > Back-end >  Apache mina2 udp client mode break line reconnection
Apache mina2 udp client mode break line reconnection

Time:10-24

With mina udp client NioDatagramConnector, if break, reconnection will be prompted to port being used, when disconnection with the dispose method, but the local port is not released, how to deal with? The framework of a bug?
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 netty

https://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 blocked
http://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 -


  • Related