I am developing bot solution, in which I am making REST call to get some details from other server.
In local host my code is working fine, but after publishing the code in Azure I am getting the below error:
System.Net.WebException: No such host is known No such host is known —> System.Net.Http.HttpRequestException: No such host is known —> System.Net.Sockets.SocketException: No such host is known
I am using HttpWebRequest option.
May I know what could be the reason?
I'm not sure the solution below will work for you but it looks like the solution is worth to be checked out. Here is an answer that may have useful information. Take a look at this answer and check your solution accordingly:
The problem description:
I deployed a .NET Windows Service on Azure Virtual Machine running
Windows Server with an opened port that allow me to connect to it,
this service is like a server using socket. The problem is that when I
try to connect from my PC to that hosted server it doesn't work and I
get this exception: System.Net.Sockets.SocketException: 'No such host
is known'. The port is opened and visible from my PC. Can someone tell
me why I get that exception? If I run locally all works ok.
The answer:
The Exception seems to be a DNS issue. I am not familiar with C#, from
networking, you could check the followings on your side:
Windows service is running and the port is listening on the Azure VM.
The port is allowed for outbound traffic from your PC and Inbound
traffic on your Azure VM. Check the VM firewall settings on both sides
between your PC and Azure VM. Also, you could check the NSG settings
follow this. You could use telnet vmpublicIP port on your PC CMD to
verify network connectivity.
Verify your PC can resolve the address of the hosted server if you connect
it via its DNS name. You could use the NSlookup or DIG to verify this.
If it's DNS issue, you also could add a line in hosts file (located in
%WINDIR%\system32\drivers\etc on windows) mapping the hosted server's
IP to a name. Hope this helps.
.NET Service System.Net.Sockets.SocketException: 'No such host is known'
Related
I deployed a .NET Windows Service on Azure Virtual Machine running Windows Server with an opened port that allow me to connect to it, this service is like a server using socket. The problem is that when I try to connect from my PC to that hosted server it doesn't work and I get this exception: System.Net.Sockets.SocketException: 'No such host is known'. The port is opened and visible from my PC. Can someone tell me why I get that exception? If I run locally all works ok.
The Exception seems to be a DNS issue. I am not familiar with C#, from networking, you could check the followings on your side:
Windows service is running and the port is listening on the Azure VM.
The port is allowed for outbound traffic from your PC and Inbound traffic on your Azure VM. Check the VM firewall settings on both sides between your PC and Azure VM. Also, you could check the NSG settings follow this. You could use telnet vmpublicIP port on your PC CMD to verify network connectivity.
Verify your PC can resolve the address of hosted server if you connect it via its DNS name. You could use the NSlookup or DIG to verify this. If it's DNS issue, you also could add a line in hosts file (located in %WINDIR%\system32\drivers\etc on windows) mapping the hosted server's IP to a name.
Hope this helps.
I am using a 3rd-party tool that runs as a Microsoft Service on a Windows Server 2008 R2 machine. The machine is using a Dell SonicWall firewall. The tool has defined ports that it is listening on of which I have opened one. Using an external web tool that port is listed as open. The service has been installed and shows as running when I run services.msc.
Everything runs great on my local machine. However, when I try to query the service I get a 403 error. The following is what the query URL looks like:
https://{siteUrl}:{portNumber}/scanservice/v2/getstatus?method=jQuery111106758983342442662_1428439579840&_=1428439579841
This is an AJAX GET request coming from an ASP.NET MVC application.
The code attempts to find an open port by querying 3 ports that are the https ports for the service. The first two are ports that I have not opened on the machine. These queries time out which is what I would expect. The last port is the one I have opened on the server. I immediately get a 403 error.
Is there somewhere where I need to expressly allow that service, not just the port?
It is a case where your public IP is not whitelisted on the web service hosting server
I am running a client application which should connect to a server side application in .NET.
Are there any restrictions on the number of connections a listening port can receive on the server?
I'm asking because I got an exception Message:
No connection could be made because the target machine actively refused it 1.9.64.212:62131
The error "No connection could be made because the target machine actively refused it" means that your request got through so it is not a firewall issue. This message means that noone listens to this port. Make sure your server application is running and that it listens to the right port number (and IP address). On your server computer you can run "netstat -a -b" to find port numbers and server applications that listen to those ports.
There are some possible reasons for that:
The server is not running. Hence it wont listen to that port. If it's a service you may want to restart the service.
The server is running but that port is blocked by Windows Firewall or other firewall. You can enable the program to go through firewall in the Inbound list.
There is a security program on your PC, i.e a Internet Security or Antivirus that blocks several ports on your PC.
I've seen this message when your service throws an unhandled exception, so check that.
This must be a firewall issue (or another connectivity issue), or the server was not started correctly.
I have a WCF self-hosted service in a Windows Forms application. I am going to be using it so a hand-held mobile device can interact with the application at a basic level.
I have enabled basicHttp (http://localhost:8080/tagservice/basic), NetTCP (net.tcp://localhost:8888/tagservice), and basicHttpMex as endpoints.
For testing purposes, I have setup a virtual machine on the network (and repeated these on a physical machine as well).
These endpoints all work on the local machine where the service is hosted.
However when running the WCFTestClient on remote machines I get mixed results.
Using the above endpoints, I can connect to the service and see the service contracts, proving the mex (IMetadataExhange) works. But I cannot use either http or net.tcp. I get the error message
Could not connect to http://localhost:8080/tagservice/basic. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8080.
Could not connect to net.tcp://localhost:8888/tagservice. The connection attempt lasted for a time span of 00:00:01.0014400. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8888.
When changing localhost to the real IP address in the app.config on the host, in this case 192.168.0.61. Basic HTTP works. However net.icp fails with
"The server has rejected the client credentials."
My two questions are:
Why is the net.tcp failing? I am not given a choice to enter credentials as far as I can tell.
Given the IP address can change, how can I get the app.config to use the IP address it is assigned by the DHCP server? As once this software moves from development to production environment the IP address cannot be hardcoded as it will change.
Build and configure the client binding at runtime, so you can programmatically set the URL based on the machine information
Something like this should work
string hostName = System.Net.Dns.GetHostName();
int port = 8080;
Uri serviceUri = new Uri(string.Format("http://{0}:{1}", hostName, port.ToString()));
EndpointAddress endpoint = new EndpointAddress(serviceUri);
Then you just attach that endpoint to your client and it should all hook up.
You can replace localhost to your hostname (if IP address is dynamic) or IP address(if static) and recompile your client.
I am writing silverlight 3 application which is working on network.
It works like client-server application. There is WinForm application for server and silverlight application for client.
I use TcpListener on server and connect from client to it with Socket.
In local network it works fine, but when I try to use it from internet it don't connect to server.
I use IP address on local network and real IP with port number for internet version.
I get error 10013 AccessDenied.
Port number is correct and access policy exist.
Firewall is turned of.
Where is the problem?
Thanks.
Have you tried to check the general availability of the connection from your machine to the Internet server with telnet ?
The problem was that computer, where hosted website hasn't real IP address, and I couldn't connect to it from internet. I added Real IP address and everything works fine now.