Every week in my Tuesday Lunch & Learn livestream, we choose a useful software development skill, define a challenge related to that skill, and solve the challenge live. This week, we’re timing out network requests.
Not all server failures are clear-cut. Sometimes servers accept a connection, but then just leave it open without sending a response, or trickle out data one byte at a time. Your normal error-handling code won’t do anything about this. To your code, everything will appear to be working, even though the server is functionally broken.
As a result, it’s important to program your clients to recognize a “stuck” server. And, of course, if you’re going to program it, you need to be able to test it. How can you write a fast unit test that simulates a misbehaving server? How can you program your application code to time out? We answer these questions in today’s episode.
To follow along, download the code from https://github.com/jamesshore/livestream and check out the 2020-09-15 tag. To see the final result, check out the 2020-09-15-end tag or view it on GitHub at https://github.com/jamesshore/livestr....
Visit the Lunch & Learn archive at https://www.jamesshore.com/v2/project... for more.