It is interesting the small things we can do to make things work very well. I have been working on my server and have had it close every now and then. This means it will work, then randomly it will break.
Initially it was because I was getting a /favicon.ico
request. I found a work around, where I had a placeholder at my previous page, and if that request came through I called my previous page. This may not be the best idea but it is one that has worked so far.
The other problem is that randomly I will be getting null
values from my buffered reader.
BufferedReader bufferedReader = new BufferedReader(input);
This is what kept breaking my server. And of course this would take time to restart the server, every time it broke.
I needed to fix this bug ASAP.
I was able to find the simplest solution that is quite useful.
if (request == null) {
continue;
}
This now allows me to keep my server running even if the request is null.
I have had no problems since!
Best,
Merl