角度发送请求时redis崩溃

时间:2019-09-12 15:30:37

标签: angular linux sockets go

我有一个带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 没关系,但是当我的角度项目在几秒钟后每1.5秒发送一次请求时log.Print(err)打印以下错误:

阅读tcp 127.0.0.1:35874->127.0.0.1:6379:使用封闭的网络连接

我尝试了所有解决方案,例如:stackoverflow github 并且端口35874有时会更改

0 个答案:

没有答案