您的位置:首页 > 移动开发

【Azure 应用服务】遇见“无法创建hybrid connection for App Service”的解决办法

2021-05-24 20:15 1631 查看

Hybrid Connection (混合连接) 在两个联网应用程序之间启用了双向、请求-响应和二进制流通信以及简单的数据报流。通过混合连接,可以实现应用部署在公网环境中,而数据库保存在本地私网环境中,他们之间通过(HCM: 混合连接器)实现双向通信。

工作原理

混合连接要求将中继代理部署到可以同时到达所需终结点和 Azure 的位置。 中继代理混合连接管理器 (HCM) 通过端口 443 调用 Azure 中继。 在 Web 应用站点上,应用服务基础结构还代表应用程序连接到 Azure 中继。 通过已联接的连接,应用可以访问所需的终结点。 连接使用 TLS 1.2 来确保安全,使用共享访问签名 (SAS) 密钥进行身份验证和授权。

问题描述

在参照设置文档 “Azure 应用服务混合连接” 一步一步配置好HCM(Hybrid Connection Manager: 混合连接管理器)后,使用数据库的IP地址作为配置的Endpoint,在HCM中显示,状态为connected,但是应用中连接DB时,出现错误。无法动过HCM的方式成功连接到DB。

配置显示成功截图:

应用错误消息:

an error occured: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')

问题解答

客户端无法连接到其终结点的主要原因是使用 IP 地址而不是 DNS 名称指定了终结点。 

如果应用无法访问所需的终结点,而你使用了 IP 地址,请改为使用在运行 HCM 的主机上有效的 DNS 名称。 另请检查 DNS 名称是否能够在运行 HCM 的主机上正确解析。 确认运行 HCM 的主机是否与混合连接终结点建立了连接。

If your status says Connected but your app cannot reach your endpoint then:

  • make sure you are using a DNS name in your Hybrid Connection. If you use an IP address then the required client DNS lookup may not happen. If the client running in your web app does not do a DNS lookup, then the Hybrid Connection will not work
  • check that the DNS name used in your Hybrid Connection can resolve from the HCM host. Check the resolution using nslookup EndpointDNSname where EndpointDNSname is an exact match to what is used in your Hybrid Connection definition.
  • test access from your HCM host to your endpoint using the PowerShell command Test-NetConnection EndpointDNSname -P Port If you cannot reach the endpoint from your HCM host then check firewalls between the two hosts including any host-based firewalls on the destination host.

解决办法

把配置在HCM连接中的Endpoint中改为数据库的主机名,如果是域环境,必须是完整的,可解析的DNS。(安装HCM的机器和真实的DB机器之间可以成功nslookup 且 test-netconnection 成功)

 

参考文档

Azure 应用服务混合连接:https://docs.azure.cn/zh-cn/app-service/app-service-hybrid-connections#troubleshooting

Using Azure App Services with Hybrid Connections:https://www.cnblogs.com/lulight/articles/14786533.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐