uWebSockets.js icon indicating copy to clipboard operation
uWebSockets.js copied to clipboard

Allow specifying a WS closing code to TemplatedApp.close()

Open dragosnicolae opened this issue 4 months ago • 3 comments

Hello,

As per documentation, the TemplatedApp.close() method "closes all sockets including listen sockets". For WS servers this means that all WS connections are closed without a closing code (I'm guessing the underlying TCP socket is the one that is actually closed) and the reported code is 1006.

It would be useful to have a way for specifying the WS closing code to send to the clients. This way, applications can identify and handle on the client side the situation of a server being closed.

dragosnicolae avatar Aug 20 '25 14:08 dragosnicolae

App.close is forceful close so there is no code, App.end is graceful end so you can pass code & reason. I'm pretty sure this is implemented

uNetworkingAB avatar Aug 20 '25 16:08 uNetworkingAB

The two methods you are mentioning do exist, but on the Websocket class, I'm already using end(code) from there. However, App only has the close method documented. The wrapper code also seems to expose only the close method: AppWrapper.h.

dragosnicolae avatar Aug 20 '25 21:08 dragosnicolae

Aha so it's not implemented

uNetworkingAB avatar Aug 20 '25 22:08 uNetworkingAB