Skip to content

Commit

Permalink
add tcp keep alive option for signal connections
Browse files Browse the repository at this point in the history
  • Loading branch information
ffdfgdfg committed Oct 5, 2020
1 parent 0a2adcb commit 5318d76
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ func (s *Bridge) typeDeal(typeVal string, c *conn.Conn, id int, vs string) {
c.Close()
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
if v, ok := s.Client.LoadOrStore(id, NewClient(nil, nil, c, vs)); ok {
if v.(*Client).signal != nil {
Expand Down

0 comments on commit 5318d76

Please sign in to comment.