When a user quits ungracefully ejabberd needs a very long time to notice this and mark the user as offline. Every message sent to the user in this time is completely lost. Is it possible to change the timeout and maybe to preserve the messages, if the other side is not alive anymore?
ejabberd opens sockets in keepalive mode, so it is up to the TCP stack on the Operating System to detect dead connections. More information on how to configure keepalive settings: