Connection Error on Microsoft Bot after publishing it on AWS - c#

I am trying to publish a bot that I coded in C# through visual studio 2015 on to AWS. I installed the Amazon Cloud SDK and was able to successfully publish the bot to AWS. I updated the bot endpoint with the address it gave (http://benbot-dev.us-west-2.elasticbeanstalk.com/). But when I go to Microsoft Bots site and test the bot connection it says Unable to connect to the remote server. Please help. I am thinking it is the https endpoint issue. But I am not sure how to get an API Gateway endpoint, if I should.
<<<<<<<<<<
500 InternalServerError
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: 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 52.42.245.162:443
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Intercom.DevPortal.Server.Controllers.BotManagerController.<PingV3BotAsync>d__54.MoveNext() in C:\a\1\s\DevPortalLib\Controllers\BotManagerController.cs:line 1420
>>>>>>>>>>>>>>>>

This exception message tells you that within your server code you are trying to reach server at 52.42.245.162, and this server is inaccessible (more specifically, https port 443 is inaccessible). This IP resolves to some AWS host (use nslookup command to find this out, see this answer). You can try to ping this IP, or try to see if port 80 is accessible (both are not from my host). Or you can try to enumerate if any other ports are open on that host (search google/bing for instructions how to do that). If you can't reach that port from your host, Microsoft Bots site can't reach it either. If your service is running on that IP, the most probably cause is that you have to open the port on AWS to be accessible from public internet (search google/bing for aws open port or aws allow ssh)

Related

System.Net.WebException: Unable to connect to Remote Server - Server in LAN only

In order to develop a Windows Universal App for my company, I need to connect to our local webserver. To test this, I have a xampp installation on my dev machine, which I used to develop around 5 applications for some Windows CE devices with no problems so far. Now we want to use Tablets too, for very specific Usecases.
My first ModernUI app's only purpose is to send a WebRequest to the Server and display the response in a TextBox with this Code I'm using:
public async Task<string> Request(string uri)
{
WebRequest request = WebRequest.Create(uri);
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
return responseFromServer;
}
If I run this app locally on my machine (with webserver being localhost), everythings works fine. But if I run it on the tablet, I get the following Exception:
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: Der Zugriff auf einen Socket war
aufgrund der Zugriffsrechte des Sockets unzulässig 10.0.0.146:80
(Translation: Access to a socket was forbidden by its access
permissions for the socket)
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)\r\n
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult,
Exception& exception)\r\n --- End of inner exception stack trace
---\r\n at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n at
System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult
iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean
requiresSynchronization)\r\n--- End of stack trace from previous
location where exception was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at
WaWiDemoWin8.ServerRequest.<Request>d__0.MoveNext()\r\n--- End of
stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at
WaWiDemoWin8.MainPage.d__0.MoveNext()"
Please be aware, that the access to the webserver by browser is possible and if I download an online webpage like google.com it works just fine (from the tablet). I even installed a new webserver on a different machine to test this, but only get the same Exception, when I try to access this webserver in our LAN.
I hope, someone can give a solution or a hint at least, because I really have no clue, what the problem is causing. If you need further information, just tell me and I will provide them asap.
Thank you,
Daniel
I'm assuming that this is a store app. Bearing this in mind, it looks like your app doesn't have permission to access the network.
If you take a read of App capability declarations (Windows Runtime apps), you'll see:
While you’re developing and testing your Windows Phone Store app app in Visual Studio, you get the networking capability (Internet (Client & Server)) when you run the app, even if you haven’t specified this capability in the app manifest file. When you publish your app, however, your app does not automatically get the networking capability. Make sure you check the Internet (Client & Server) capability on the Capabilities page of Manifest Designer if your app requires network connectivity.
You'll need to add one of the network permissions to the app Capabilities in the app manifest.

wcf client reporting SSL exception only on one occasion

Our WCF client normally invokes a web service. All deployments of the client invoke the same web service. In most deployments it makes the call without any issues, except in one instance it reports the following exception:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
What could be different with this one installation?
We tested the URL that the client uses to make the call to the web service in the browser. The web service returns a response ok in Firefox but not in IE.
Have you seen this article yet? It contains fairly good tips for troubleshooting these issues: http://blogs.msdn.com/b/jpsanders/archive/2009/09/16/troubleshooting-asp-net-the-remote-certificate-is-invalid-according-to-the-validation-procedure.aspx?Redirected=true
For example, you'll need to check that the particular machine has all the root and intermediate certificates properly deployed.
I found the solution - there was a new web service server certificate installed with SHA256 and Windows 2003 Server requires a hotfix to support it:
http://support.microsoft.com/kb/938397

adding reference for wsdl service in windows service and using its function in c#

I have a windows service using C#(windows application) which performs a set of various functions.
But recently it was required to use a wsdl service (a url was provided) whose functions I have to use in my code.
Although I have never done it before but if I am not wrong we add the service reference creates its instance and then call its function.
I have done all these successfully.
But when i execute the service I get end point not found exception something like as below..
System.ServiceModel.EndpointNotFoundException: Could not connect to http://localhost:8082/quali-jaxrpc/quali. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8082. ---> 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 127.0.0.1:8082
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
--- End of inner exception stack trace ---
The problem is that the service is already running on the server itself but yet it is giving this exception..
Am I doing something wrong?
Please note that my service is not WCF its windows service.
When I added the service reference of the WSDL in appconfig following was created-
<endpoint address="http://localhost:8082/qualicision-jaxrpc/qualicision"
So i just replaced the localhost with the IP of the server.
Although the service is deployed on the server and windows service also running on same but still adding actual IP of the server in place of localhost worked.

A connection attempt failed because the connected party did not properly respond after a period of time or connected host has failed to respond

I'm developing a windows service, that downloads images from a specific URL. The service runs correctly on my computer but when I install it in the server it does not download the image and it gives the following error:
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: 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 212.100.220.117:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadData(Uri address)
at System.Net.WebClient.DownloadData(String address)
What might be causing the error and how can I resolve it?
I read this page:
http://support.microsoft.com/kb/318140
I'm not sure if this is the problem, and if it is what proxy should I write in the config. Asking you for your advice.
I found the answer. I was trying to access the public address "http://mywebsite.com/images/" from the server. Instead of that I used the local IP of the server hosted the website and it's now working.
In this case it might be possible that port 80 is not open. Create an inbound and outbound rule in firewall setting to open port 80. Still, if the issue exists try with disabling the antivirus, It might be possible that antivirus is blocking the port.
In my case I had to modify the Logon settings of the Windows Service in the Windows Service console then used domain administrator account to run the service instead of the regular Local System/Service account then It started working properly.
If you are working, this could indicate that you aren't connected to your VPN.

WebException: Unable to connect to the remote server

I have a client application that uses WebHttpRequest to get response from external server, it works fine but some times I'm getting the following exception ....
System.Net.WebException: Unable to
connect to the remote server --->
System.Net.Sockets.SocketException: 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
xx.xx.xxx.xxx:xxx at
System.Net.Sockets.Socket.DoConnect(EndPoint
endPointSnapshot, SocketAddress
socketAddress) at
System.Net.Sockets.Socket.InternalConnect(EndPoint
remoteEP) at
System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6,
Socket& socket, IPAddress& address,
ConnectSocketState state, IAsyncResult
asyncResult, Int32 timeout, Exception&
exception) --- End of inner
exception stack trace ---
at
System.Net.HttpWebRequest.GetRequestStream(TransportContext&
context)
at
System.Net.HttpWebRequest.GetRequestStream()
.... Any help?
This is more of a "Request Timed Out" error. The server you are trying to connect to did not respond to your request. You should handle this exception using try-catch and attempt to connect n number of times again in the catch block.

Categories