The websocket RFC says this about status 1006:
1006 is a reserved value and MUST NOT be set as a status code in a
Close control frame by an endpoint. It is designated for use in
applications expecting a status code to indicate that the
connection was closed abnormally, e.g., without sending or
receiving a Close control frame.
The websocket package documention says:
SetCloseHandler sets the handler for close messages received from the peer
The close handler was not called because a close message was not received. The peer closed the connection without sending a close message.
The package documentation also says:
The connection read methods return a CloseError when a close message is received. Most applications should handle close messages as part of their normal error handling. Applications should only set a close handler when the application must perform some action before sending a close message back to the peer.
Because the handler in the question does not send a close message or take any other action, the close handler in the question is not needed. The handler is harmful because it does not echo the close message.
Delete the close handler and handle close messages as part of the application's normal error handling.