Ws: WebSocket.terminate() vs WebSocket.close()

Created on 23 Jun 2019  路  1Comment  路  Source: websockets/ws

On readme:
// UseWebSocket#terminate()and notWebSocket#close().

There is this line. But it does not explain why, and I dived into the codebase and the issues but still could not find a reason. Can we include this information somewhere?

Most helpful comment

ws.terminate() immediately destroys the connection, ws.close() waits for close timer to expire before destroying the connection if the other peer is not responsive.

Technically both can be used but ws.terminate() is better in that example (you don't want to wait another 30 sec before the websocket emits the 'close' event). Feel free to open a PR.

>All comments

ws.terminate() immediately destroys the connection, ws.close() waits for close timer to expire before destroying the connection if the other peer is not responsive.

Technically both can be used but ws.terminate() is better in that example (you don't want to wait another 30 sec before the websocket emits the 'close' event). Feel free to open a PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Globik picture Globik  路  3Comments

pacmac picture pacmac  路  3Comments

ORESoftware picture ORESoftware  路  3Comments

HanHtoonAung picture HanHtoonAung  路  3Comments

dcflow picture dcflow  路  4Comments