Im deploying docker containers on my local machine. They way I check that they are successfully deployed is by going to my browser and typing http://192.168.99.105:7474/browser
. I would like to do this programmatically so I followed the code in this question Check if a url is reachable - Help in optimizing a Class. However when I try it, I get a System.Net.WebException {"The remote server returned an error: (504) Gateway Timeout."}
.
It works fine though and I get a HttpStatusCode.OK
if the url is https://en.wikipedia.org/wiki/YouTube
This is my code:
private bool UrlIsReachable(string url)
{
//https://en.wikipedia.org/wiki/YouTube
HttpWebRequest request = WebRequest.Create("http://192.168.99.105:7474/browser") as HttpWebRequest;
request.Timeout = 600000;//set to 10 minutes, includes time for downloading the image
request.Method = "HEAD";
try
{
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
return response.StatusCode == HttpStatusCode.OK;
}
}
catch (WebException)
{
return false;
}
}
EDIT: My docker-compose.yml file
version: '2'
services:
company1:
image: neo4j
ports:
- "7474:7474"
- "7687:7687"
volumes:
- $HOME/company1/data:/data
- $HOME/company1/plugins:/plugins
company2:
image: neo4j
ports:
- "7475:7474"
- "7688:7687"
volumes:
- $HOME/company2/data:/data
- $HOME/company2/plugins:/plugins