Embedded BaseX server restart
Tuesday, 23 August 2011 · 2 messages
IF
Igor Farinic23 Aug 2011 10:25 #
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
MS
Michael Seiferle23 Aug 2011 11:20 #
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
Quoted text · Igor Farinic · 27 lines
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 at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Written for BaseX 6.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery