mirror of https://github.com/ehang-io/nps
add tcp keep alive option for signal connections
parent
b4604bc4da
commit
894d0c7503
|
@ -233,6 +233,12 @@ func (s *Bridge) typeDeal(typeVal string, c *conn.Conn, id int, vs string) {
|
||||||
c.Close()
|
c.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
tcpConn, ok := c.Conn.(*net.TCPConn)
|
||||||
|
if ok {
|
||||||
|
// add tcp keep alive option for signal connection
|
||||||
|
_ = tcpConn.SetKeepAlive(true)
|
||||||
|
_ = tcpConn.SetKeepAlivePeriod(5 * time.Second)
|
||||||
|
}
|
||||||
//the vKey connect by another ,close the client of before
|
//the vKey connect by another ,close the client of before
|
||||||
if v, ok := s.Client.LoadOrStore(id, NewClient(nil, nil, c, vs)); ok {
|
if v, ok := s.Client.LoadOrStore(id, NewClient(nil, nil, c, vs)); ok {
|
||||||
if v.(*Client).signal != nil {
|
if v.(*Client).signal != nil {
|
||||||
|
|
Loading…
Reference in New Issue