TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.47k stars 2.57k forks source link

Unable to catch port binding Exception #1415

Closed LiJianGuo123 closed 3 months ago

LiJianGuo123 commented 3 months ago

How to catch the error that the service starts and the port is still bound, I can't get the Exception through the Try Catch Start method

PhilipRoman commented 3 months ago

Hi, the exception will be passed to the onError callback of the server, you can handle it there.

By the way, if you're dealing with port binding issues, you may be intrested in setReuseAddr which helps avoid this when quickly restarting the service