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

nabeelio picture nabeelio  路  5Comments

brainkim picture brainkim  路  4Comments

ImBundle picture ImBundle  路  3Comments

anonaka picture anonaka  路  5Comments

sherikapotein picture sherikapotein  路  3Comments