Skip to content

Commit 432ff20

Browse files
rlubosmbolivar-nordic
authored andcommitted
net: websockets: Fix websocket close procedure
The websocket implementation did not comply with the RFC 6455 when it comes to connection close. The websocket should send in such case Close control frame. This commit fixes this behaviour. Signed-off-by: Robert Lubos <[email protected]>
1 parent 7f02199 commit 432ff20

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/net/lib/websocket/websocket.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ static int websocket_interal_disconnect(struct websocket_context *ctx)
419419

420420
NET_DBG("[%p] Disconnecting", ctx);
421421

422+
ret = websocket_send_msg(ctx->sock, NULL, 0, WEBSOCKET_OPCODE_CLOSE,
423+
true, true, SYS_FOREVER_MS);
424+
if (ret < 0) {
425+
NET_ERR("[%p] Failed to send close message (err %d).", ctx, ret);
426+
}
427+
422428
ret = close(ctx->real_sock);
423429

424430
websocket_context_unref(ctx);

0 commit comments

Comments
 (0)