How to simulate network failure or server is down by using Charles Proxy Black List
There are multiple ways to simulate network failure or simulate server is down at sever end, then we can check how client app behaves when encounter such issues. Charles Proxy provide such function to help us to simulate network failure and server down situations. We will give an example for how to using this function from Charles.Here is a way that you can set up a black host list in Charles Proxy to simulate network failure or server is unreachable for the specific hosts that you want to block. Charles gives 2 ways to block the hosts. One way is to drop the connection. And the other way is to return 403 response. And you just need to add a host to the list that you want to block. Go ahead to check the More details.
Let's go through the steps one by one. First thing you need to do is to go to Black List to add host to the list, and set up proper property stetting with each host that you want to block, the select Block Action either "Drop connection" or "Return 403 response".
For details, please check this video for how to block the host list in Charles proxy. .
If you have not installed Charles Proxy, please go to Charles Proxy website to download application for your PC platform and install it.
There are a lot of response errors over HTTP, the typical error responses listed as below here:
HTTP 200 "OK"
HTTP Error 204 "No Content"
HTTP Error 301 "Moved Permanently"
HTTP Error 302 "Found" or "Moved Permanently"
HTTP Error 400 "Bad Request"
HTTP Error 401 "Unauthorized"
HTTP Error 403 "Forbidden"
HTTP Error 404 "Not found"
HTTP Error 500 "Internal Server error"
HTTP Error 502 "Bad Gateway"
HTTP Error 503 "Service Unavailable"
Charles provides function of Black List and White List to simulate Http error 403 returned directly. But if you want to simulate above errors, you can use Charles function Breakpoints to interrupt response and update response error code before client end receives it.
Charles Black List and White List has similar function. The only difference is Black list wraps the hosts with IP and port number that you want to block. And White List will do opposite way. It will wrap a list that you don't want to block when observed the traffic. It depends on how many hosts you want to deal with at once.
We give an example with detail steps for how to create a Black List to simulate network failure or 403 response as below. With function of White List, is similar steps, you just list the hosts that you don't want black them.