set time out

pull/455/head
skiffer-git 3 years ago committed by Xinwei Xiong(cubxxw-openim)
parent c2782a4bb6
commit 7e517b9ab9

@ -97,6 +97,7 @@ func (ws *WServer) SetWriteTimeout(conn *UserConn, timeout int) {
func (ws *WServer) writeMsg(conn *UserConn, a int, msg []byte) error {
conn.w.Lock()
defer conn.w.Unlock()
conn.SetWriteDeadline(time.Now().Add(time.Duration(30) * time.Second))
return conn.WriteMessage(a, msg)
}
@ -171,7 +172,7 @@ func (ws *WServer) sendKickMsg(oldConn, newConn *UserConn) {
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "Encode Msg error", oldConn.RemoteAddr().String(), newConn.RemoteAddr().String(), err.Error())
return
}
ws.SetWriteTimeout(oldConn, 5)
// ws.SetWriteTimeout(oldConn, 5)
err = ws.writeMsg(oldConn, websocket.BinaryMessage, b.Bytes())
if err != nil {
log.NewError(mReply.OperationID, mReply.ReqIdentifier, mReply.ErrCode, mReply.ErrMsg, "sendKickMsg WS WriteMsg error", oldConn.RemoteAddr().String(), newConn.RemoteAddr().String(), err.Error())

Loading…
Cancel
Save