I am trying to make a request to Paypal endpoint via SDK in my .NET Core application. The request works on local server just fine. But when I pulished the application on 1and1 hosting server, I get this error.
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
The reason I found out is that 1and1 doesn't allow direct calls so I need to use proxy. Some people have asked the same question already. But there is no real answer for me.
Here are two of them:
- A connection attempt failed because the connected party did not properly respond
- https://forums.asp.net/t/2138734.aspx?A+connection+attempt+failed+because+the+connected+party+did+not+properly+respond+after+a+period+of+time
I also did contact 1and1 for support (2x times). They sent me the same link (in german) which I have already found and tried. No success.
Here are some senairos, that I have tried:
1. Add proxy server to web.config file
My config file looks something like this
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\MyApp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
<system.net>
<defaultProxy>
<proxy proxyaddress="http://1and1proxy:123"
bypassonlocal="true"/>
</defaultProxy>
</system.net>
</configuration>
2. Add AspNetCore.Proxy to startup.cs file
public void ConfigureServices(IServiceCollection services) {
...
services.AddProxies();
...
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
...
app.RunProxy(proxy => proxy.UseHttp("http://1and1proxy:123"));
...
}
3. Make another simple request to another server (using webproxy but also failed)
public async Task < IActionResult > callingGet() {
var proxiedHttpClientHandler = new HttpClientHandler() {
UseProxy = true
};
proxiedHttpClientHandler.Proxy = new WebProxy("http://1and1proxy:123");
HttpClient client = new HttpClient(proxiedHttpClientHandler);
using
var client = new HttpClient();
var result = await client.GetAsync("https://reqres.in/api/users/2");
return View(new Model {
Message = result.ToString()
});
}
Did I miss something here or do I have to switch to another provider? PS: this is my first time publishing a website