I'm closing websocket connection on client side via button click and logging the event, as well as have 'webSocket.onClose' logging. Both log entries indicate that websocket was closed successfully, but it's status stays 101 in the web Inspector, on the Network tab of Chrome. When I reopen websocket connection, it just adds a new websocket entry into the network tab. Server side also seems to close the connection. My code in React JS is below. Is there anything wrong with my approach?
const newSocket = new WebSocket(webSocketUrl);
newSocket.onclose = (event) => {
// Handle WebSocket closure and update the state
console.log('WebSocket closed:', event.code, event.reason);
};
render(<div>
<Button
onClick={() => socket?.close(4003, 'Clicked close socket button')}>
{'Close Socket'}
</Button>
</div>)