【问题标题】:Can't connect to Azure Cache for Redis from Azure Web App无法从 Azure Web 应用连接到 Azure Cache for Redis
【发布时间】:2021-04-15 17:04:09
【问题描述】:

我有 NodeJS Web 应用程序,它试图连接到同一订阅中的 Azure Redis 缓存。

const redis = require('redis')

const redisConnectionConfig = {
  host: REDIS_HOST,
  port: REDIS_PORT,
  auth_pass: REDIS_PASSWORD
  tls: { servername: REDIS_HOST }
}
...

 redis.createClient(redisConnectionConfig)

将我的 IP 添加到 Redis 防火墙规则后,我可以从本地计算机连接到 Redis。

此外,我已从服务应用程序属性中添加了所有“出站 IP 和其他出站 IP 地址”。

我什至尝试过允许来自所有 IP 的访问 还是没通过

但它没有连接,如果我尝试使用 Redis,我会收到以下连接错误: MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.

为 VM here 解决了类似问题。但是对于应用服务 Azure 管理该层。

【问题讨论】:

  • 我通过 ssh 连接到容器并验证了来自容器本身的 Redis 连接,你猜怎么着? - 它正在与 Redis 成功通信。实际上,在我的项目中,我使用直接 Redis 连接和基于 Redis 构建的队列 - 所以我使用不正确的连接配置初始化队列,它回退到默认值并连接到我的本地 Redis - 这就是它在本地机器上工作的原因。

标签: javascript node.js azure redis azure-webapps


【解决方案1】:

看起来不是连接问题。 您始终可以通过 WebApp->Console 和使用命令检查网络部分

tccping redisservername:redisserverport

tcpping_example

可能与您的 redis 缓存大小有关。你现在用什么尺寸的? 你可以找到 azure redis 限制here

【讨论】:

  • 谢谢!您对 ssh 到容器的可能性的暗示帮助我追踪了这个问题。这确实不是连接问题,而是应用配置问题
  • @Vasyl 很高兴为您提供帮助!随时将我的帖子标记为答案:) thx
猜你喜欢
  • 2021-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多