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

G-Rath picture G-Rath  路  51Comments

diegoaguilar picture diegoaguilar  路  23Comments

pwnall picture pwnall  路  46Comments

peradym picture peradym  路  16Comments

bugs181 picture bugs181  路  15Comments