WCF + web api + The connection cannot be made because the target machine has actively refused it xxxx: 443

I am accessing a third party web api from my WCF application. During development, I was able to access these APIs, but when I deployed my WCF to IIS, it was unable to connect to the web API and threw me the following error:

"System.Net.WebException: Unable to connect to remote server ---> System.Net.Sockets.SocketException: The connection could not be made because the target computer actively refused it. XXXX: 443"

Just to make sure my server is fine where I deployed my WCF. I tried to access these web apies from a simple console application. He accessed these apis from my development machine and from the server machine. Now I feel like the culprit is not the third party web api, but something is wrong when the WCF service accesses the IIS hosted web api.

Please, help!!!

+3


source to share


1 answer


Finally I found the problem. IIS runs my WCF under a custom "network service" or "application pool id". These are nothing more than built-in user windows that have limited access. When I tried to access a third party API from a console app, it worked because it worked under my user credentials, which have admin credentials. So I came to the conclusion that when the application makes a cross-domain call, it must be running as a user with enough credentials to make such calls.



The solution was to change the app pool id to admin user id (I changed it to my logged in user). It worked and called a third party API from a WCF service

+2


source







All Articles