Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hey all,
Perhaps this question is a bit weird... I'm doing my best to explain the issue.

So we're having a REST service (C# MVC Web API) running at http://something.com/api.
In another MVC web project we're doing some calls to the service pretty much as follows:
C#
using (HttpClient client = new HttpClient())
{
    HttpResponseMessage response = client.GetAsync("some_uri").Result;
    if (response.IsSuccessStatusCode)
    {
        return response.Content.ReadAsAsync<T>().Result;
    }
    else
    {
        // Handle error...
    }
}
So far so good, everything works fine.

The URI is coming from the config file and, as said, is something like http://something.com/api.

All is well, until all of a sudden it isn't.
What happens is that the service becomes unreachable until I change the URI in the config to httpS://something.com/api.
And that works for a while until all of a sudden I must change it back to http (without the S)...

I'm thinking it must be a client side issue because last week I had this problem and had to switch to httpS while a coworker could continue working on http. Two of my coworkers are experiencing the same problem. There doesn't seem to be any obvious trigger that makes the change to HTTP(S).

Please don't tell me I should be using httpS all the time anyway, that's not helpful.
I've tried Googling, but all I can find is browser caching, HSTS and redirects, but those can't be the problem (obviously we're not using HSTS or redirects and I'm not sure how browser caching would cause this problem).

Any ideas on what could be causing this are appreciated.
Thanks!

What I have tried:

Googling this issue with no success.
Posted
Updated 30-Mar-17 22:44pm
Comments
F-ES Sitecore 24-Mar-17 10:07am    
Is the server in a web farm or load balancer?
Sander Rossel 24-Mar-17 10:16am    
Nope, just a server we have standing around somewhere (I can't access the hardware though).
Richard Deeming 24-Mar-17 10:40am    
But you should be using HTTPS all the time! :P


What error do you get when the request fails?

Have you tried requesting the URL in a browser when it's not working? Possibly using something like Fiddler[^] to trace the requests.

Have you checked the event logs on the server that's hosting the API?
Sander Rossel 24-Mar-17 12:40pm    
I'm getting the following error: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

Gone when I change HTTP to HTTPS. Until I get it again and need to change HTTPS back to HTTP.
I can't find anything on the server.
I haven't tried requesting it using a browser. I'll try when the error occurs again.
ZurdoDev 24-Mar-17 11:49am    
As Richard said, you should be using https if ssl is enabled. But it sounds like a problem with the network or server so I'm not sure what we can do to help.

1 solution

It was a VPN connection that redirects everything to HTTPS...
I'm not usually on VPN, but lately I've been needing it on and off.
I feel stupid for not noticing it now...
Anyway, glad I know the problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900