angular - 角度发送请求时redis崩溃
问题描述
我有一个带有 redigo 的 go 服务器,我有这个功能可以从 redis 获取数据:
func findCompetition(conn redis.Conn, username string) competition{
conn.Send("KEYS", "*")
conn.Flush()
re, erre := conn.Receive()
keys, err := redis.Strings(re, erre)
if err != nil {
log.Print(re)
log.Print(err)
return competition{Username:"null"}
}
for _, key := range keys {
comp := getCompetition(conn, key)
if comp.Competitor == username &&
time.Now().Sub(comp.Time_asked).Minutes() < 2.0 {
return comp
}
}
return competition{Username:"null"}
}
当我通过浏览器发送请求时,例如:http://localhost:4500/find_competition/aicam 没关系,但是当我的 Angular 项目在几秒钟后每 1.5 秒发送一次请求时 log.Print(err) 在下面打印错误:
读取 tcp 127.0.0.1:35874->127.0.0.1:6379: 使用关闭的网络连接
我尝试了所有解决方案,例如:stackoverflow github 和端口 35874 有时会发生变化
解决方案
推荐阅读
- python - Python 类型提示类作为对象或列表
- asp.net-core - Ubuntu 20.04 上的身份脚手架使用不正确的文件路径 dotnet 5
- c# - 有没有更有效的方法在我的数据库中插入数据数组?Asp.net-core + Dapper
- mysql - 图像未插入 MySQL。错误 1048
- c++ - 宽松的内存顺序自旋锁总是会破坏同步吗?
- rxjs - 在这种情况下,如何使用 rxjs Observable 抛出错误?
- c++ - 无法在 C++ 向量中调用擦除()操作
> - c# - C# EventHandler 文档代码示例
- python - 如何使用 python tkinter 将所选图像上传到标签中?
- python - 在 Selenium/Python 中从亚马逊产品页面的图像中提取所有 src 属性