fightf
fightf

Reputation: 71

Java SocketException Maximum number of datagram sockets reached

I have a java app program run on centos 6.3 and tomcat 7 as the app container, currently I meet one error : java.io.socketexception Maximum number of datagram sockets reached

we use MulticastSocket class to send message. when this error happened, I check the current server UDP socket count with command: ss -s

Total: 212 (kernel 248) TCP: 70 (estab 15, closed 44, orphaned 0, synrecv 0, timewait 40/0), ports 22

Transport  Total     IP        IPv6
*          248       -         -        
RAW        0         0         0        
UDP        40        40        0        
TCP        26        26        0        
INET       66        66        0        
FRAG       0         0         0        

and I also check the

ulimits -n

The default setting is 32768, seem UDP socket count not exceed max count.

Any ideas for this error?

Upvotes: 0

Views: 5068

Answers (1)

user207421
user207421

Reputation: 311046

we use MulticastSocket class to send message.

Why? You only need a MulticastSocket to receive multicasts.

Obviously you are leaking MulticastSockets. Presumably you are creating a new one per message and never closing it.

Upvotes: 1

Related Questions