.NET服务System.Net.Sockets.SocketException:'未知此类主机' [英] .NET Service System.Net.Sockets.SocketException: 'No such host is known'

查看:85
本文介绍了.NET服务System.Net.Sockets.SocketException:'未知此类主机'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行Windows Server的Azure虚拟机上部署了.NET Windows服务,该服务具有打开的端口,允许我连接到该端口,该服务就像使用套接字的服务器.问题是,当我尝试从PC连接到该托管服务器时,它无法正常工作,并且出现以下异常: System.Net.Sockets.SocketException:'未知此类主机'.该端口已打开,并且在我的PC上可见.有人可以告诉我为什么我得到那个例外吗?如果我在本地运行,一切正常.

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.

推荐答案

该异常似乎是DNS问题.我不熟悉C#,从网络上来说,您可以检查一下以下内容:

The Exception seems to be a DNS issue. I am not familiar with C#, from networking, you could check the followings on your side:

  1. Windows服务正在运行,并且端口正在Azure VM上监听.

  1. Windows service is running and the port is listening on the Azure VM.

该端口允许来自PC的出站流量和Azure VM上的入站流量.检查PC和Azure VM之间的VM防火墙设置.另外,您可以按照此方法检查NSG设置.您可以在PC CMD上使用 telnet vmpublicIP端口来验证网络连接.

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.

希望这会有所帮助.

这篇关于.NET服务System.Net.Sockets.SocketException:'未知此类主机'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆