mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-22 01:22:21 +08:00
add code
This commit is contained in:
@@ -172,7 +172,7 @@ export default {
|
||||
|
||||
function safeCloseWebSocket(ws: WebSocket) {
|
||||
try {
|
||||
if (ws.readyState === WebSocket.READY_STATE_OPEN) {
|
||||
if (ws.readyState !== WebSocket.READY_STATE_CLOSED) {
|
||||
ws.close();
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -24,7 +24,11 @@ export default {
|
||||
}
|
||||
});
|
||||
webSocket.addEventListener('close', async (event) => {
|
||||
console.log('-------------close-----------------', event);
|
||||
console.log(
|
||||
'-------------close-----------------',
|
||||
event,
|
||||
webSocket.readyState
|
||||
);
|
||||
webSocket.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ export function makeReadableWebSocketStream(
|
||||
// https://streams.spec.whatwg.org/#example-rs-push-backpressure
|
||||
controller.enqueue(vlessBuffer);
|
||||
});
|
||||
|
||||
// The event means that the client closed the client -> server stream.
|
||||
// However, the server -> client stream is still open until you call close() on the server side.
|
||||
// The WebSocket protocol says that a separate close message must be sent in each direction to fully close the socket.
|
||||
ws.addEventListener('error', (e: any) => {
|
||||
log('socket has error');
|
||||
readableStreamCancel = true;
|
||||
|
||||
Reference in New Issue
Block a user