Hi,
we have problem with restart (stop and immediate start) of embedded BaseX server. The root cause is that when you close server socket it remains in a timeout state for a period of time and restart fails, because it is not possible to bind to a socket in timeout state. Enabling SO_REUSEADDR prior to binding the socket using bind allows the socket to be bound even though a previous connection is in a timeout state.
Following fix in BaseXServer class should help (lines 94 and 95):
socket = new ServerSocket(); socket.setReuseAddress(true); SocketAddress endpoint = new InetSocketAddress(port); socket.bind(endpoint);
esocket = new ServerSocket(); esocket.setReuseAddress(true); endpoint = new InetSocketAddress(context.mprop.num(MainProp.EVENTPORT)); esocket.bind(endpoint);
regards, Igor Farinic
Dear Igor,
thanks for your E-Mail, I added your proposed patch as a pull request on GitHub [1]. It should soon be merged & officical.
Thanks Michael
[1] https://github.com/BaseXdb/basex/pulls Am 23.08.2011 um 10:25 schrieb Igor Farinic:
Hi,
we have problem with restart (stop and immediate start) of embedded BaseX server. The root cause is that when you close server socket it remains in a timeout state for a period of time and restart fails, because it is not possible to bind to a socket in timeout state. Enabling SO_REUSEADDR prior to binding the socket using bind allows the socket to be bound even though a previous connection is in a timeout state.
Following fix in BaseXServer class should help (lines 94 and 95):
socket = new ServerSocket(); socket.setReuseAddress(true); SocketAddress endpoint = new InetSocketAddress(port); socket.bind(endpoint); esocket = new ServerSocket(); esocket.setReuseAddress(true); endpoint = new InetSocketAddress(context.mprop.num(MainProp.EVENTPORT)); esocket.bind(endpoint);
regards, Igor Farinic _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de