No such host is known socket connection

前端 未结 3 989
野的像风
野的像风 2020-12-19 10:34

I\'m trying to work with this library for telnet connections. I have called the function correctly and it executes the code below but fails giving the following error:

相关标签:
3条回答
  • 2020-12-19 11:17

    Related but rare/fringe case: I was getting this same error in my C# .NET 4.7.2 web app (calling a http endpoint) because the machine I was on (a Parallels Win10 VM) had silently lost its network connection (no internet) due to some Parallels bug. Once I disabled and re-enabled the network adapter the error went away. /eyeroll

    0 讨论(0)
  • 2020-12-19 11:23

    The solution was something quite easy and overlooked. First I noticed that the tcpclient prefers an ip address and not a name. Then I also realized that sometimes there were extra spaces on either side of the domain name. So I used the below code to strip the characters and change it to an ip.

    string.Trim();
    //Telnet Start
    IPHostEntry hostInfo = Dns.Resolve(hostnamehere);
    
    0 讨论(0)
  • 2020-12-19 11:32

    I'm going to put this answer in here for people who are getting this error like me, who never seemed to find an answer:

    If you're trying to grab a client hostname from the DNS server within your company's network using: Dns.GetHostEntry(ClientIP) and each time you keep getting the "No such host is known socket connection error," your DNS server may not have Reverse Lookup Zones set for the IP range you're passing in code.

    For example, I have a program that works with our web application that captures the computer name and IP address of the employee submitting a help request. It worked if the computer using the application was on a vlan that was in the reverse lookup zone.

    If you have access to your domain's DNS server, add reverse lookup zones for all of the IP addresses that you use on your domain, or have your network administrator do it.

    Always have a try catch around it, just in case you have a situation where someone accesses your webapp from outside of your network.

    Knowing this would have saved me hours of frustration.

    0 讨论(0)
提交回复
热议问题