Generic method to avoid server crash.
Merge pull request #2968 from sebv/server-crash

Generic method to avoid server crash.