Skip to content

Commit

Permalink
Merge pull request #54 from libp2p/fix/graceful-close
Browse files Browse the repository at this point in the history
fix: close gracefully
  • Loading branch information
Stebalien authored Sep 30, 2019
2 parents ac7f16b + 7f87ef8 commit 4b1b551
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion p2p/transport/websocket/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func (c *Conn) Write(b []byte) (n int, err error) {
func (c *Conn) Close() error {
var err error
c.closeOnce.Do(func() {
err1 := c.Conn.WriteControl(ws.CloseMessage, nil, time.Now().Add(GracefulCloseTimeout))
err1 := c.Conn.WriteControl(
ws.CloseMessage,
ws.FormatCloseMessage(ws.CloseNormalClosure, "closed"),
time.Now().Add(GracefulCloseTimeout),
)
err2 := c.Conn.Close()
switch {
case err1 != nil:
Expand Down

0 comments on commit 4b1b551

Please sign in to comment.