basex-node does not handle server disconnection gracefully #9
Labels
No labels
dependencies
javascript
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
quodatum/basex-node#9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
when leaving my node process connected to BaseX running over night, it crashed when it lost connection to the database server. It seems that there is currently no way to prevent this, as node-basex does not handle the possible closing of the socket by the database server, and tries to interact with a closed socket, which results in an uncaught exception.
It would be useful if an event would be generated when a Session lost its connection (by making it an EventEmitter and forwarding the 'end' event). Furthermore, session.close() should detect when the socket is already closed and not try to read or write from it in that case.
This would allow application code to set up an event handler that logged the event and performed an automatic reconnection, if desired.
I can come up with a patch if you don't have the time to look into implementing this yourself. Please let me know.
Thanks!
Hans
Hi Hans,
Handling disconnection and reconnect has been on the TODO list for a while :-). Your event proposal seems fine to me. If it is something you are looking for quickly I am very happy to take patches or pull requests.
I noticed today that after leaving my application running with no requests for a few days and then trying to process an action, it just hung. I need to debug further but I suspect that the BaseX session got disconnected and my app tried to use the invalid session.
I can work around by creating a new session per request but that seems less than ideal.
I'm willing to help implement disconnect handling if you would like to discuss the best solution.
Very happy to have your help on this. I dont really have a solution in mind, two approaches are:
simple-basex has this emit mechanism which seems like a good starting point
https://github.com/hanshuebner/simple-basex/blob/master/index.js#L64
@hanshuebner Do you have any thoughts on this?
node_redis, which was an inspiration when starting basex-node, has much more
https://github.com/mranney/node_redis/blob/master/index.js#L442
2014-04-04 19:00 GMT-04:00 Andy Bunce notifications@github.com:
I cannot comment on how hard or easy it would be to use the same strategy
of forwarding events to the application work in basex-node.
See
examples/issue11.jsfor one approach