简体   繁体   English

.NET服务System.Net.Sockets.SocketException:'未知此类主机'

[英].NET Service System.Net.Sockets.SocketException: 'No such host is known'

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. 我在运行Windows Server的Azure虚拟机上部署了.NET Windows服务,该服务具有打开的端口,允许我连接到该端口,该服务就像使用套接字的服务器。 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' . 问题是,当我尝试从PC连接到该托管服务器时,它无法正常工作,并且出现以下异常: System.Net.Sockets.SocketException: 'No such host is known' The port is opened and visible from my PC. 端口已打开,并且在我的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. 异常似乎是DNS问题。 I am not familiar with C#, from networking, you could check the followings on your side: 我对C#不熟悉,从网络上来说,您可以检查以下方面:

  1. Windows service is running and the port is listening on the Azure VM. Windows服务正在运行,并且端口正在Azure VM上侦听。

  2. The port is allowed for outbound traffic from your PC and Inbound traffic on your Azure VM. 该端口允许来自PC的出站流量和Azure VM上的入站流量。 Check the VM firewall settings on both sides between your PC and Azure VM. 检查PC和Azure VM之间的VM防火墙设置。 Also, you could check the NSG settings follow this . 另外,您可以按照检查NSG设置。 You could use telnet vmpublicIP port on your PC CMD to verify network connectivity. 您可以在PC CMD上使用telnet vmpublicIP port来验证网络连接。

  3. Verify your PC can resolve the address of hosted server if you connect it via its DNS name. 如果通过其DNS名称连接主机,请确认您的PC可以解析托管服务器的地址。 You could use the NSlookup or DIG to verify this. 您可以使用NSlookupDIG进行验证。 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. 如果是DNS问题,您还可以在主机文件中添加一行(位于Windows上的%WINDIR%\\system32\\drivers\\etc中),以将托管服务器的IP映射到名称。

Hope this helps. 希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.Net.Sockets.SocketException (0x80004005): 没有这样的主机是已知的 - System.Net.Sockets.SocketException (0x80004005): No such host is known System.Net.Sockets.SocketException - System.Net.Sockets.SocketException SFTP 连接中的 C# 错误。 异常:System.Net.Sockets.SocketException (11001):不知道这样的主机 - C# Error in SFTP connection. Exception: System.Net.Sockets.SocketException (11001): No such host is known postgres 连接上的 System.Net.Sockets.SocketException - System.Net.Sockets.SocketException on postgres connection System.Net.Sockets.SocketException 灾难 - System.Net.Sockets.SocketException Disaster 从对象类型System.Net.Sockets.SocketException到已知托管提供程序本机类型的映射不存在 - No mapping exists from object type System.Net.Sockets.SocketException to a known managed provider native type System.Net.Sockets.SocketException(0x80004005):建立的连接已被主机中的软件中止 - System.Net.Sockets.SocketException (0x80004005): An established connection was aborted by the software in your host machine System.Net.Sockets.SocketException:无法解析主机-Mono上的自托管Nancy应用 - System.Net.Sockets.SocketException: Could not resolve host - Self-hosted Nancy app on Mono 2008R2服务器上的System.Net.Sockets.SocketException - System.Net.Sockets.SocketException on 2008R2 Server EventHub 发送消息,但 Application Insights 上的 System.Net.Sockets.SocketException - EventHub send message, but System.Net.Sockets.SocketException on Application Insights
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM