Commit 432ff20a authored by Robert Lubos's avatar Robert Lubos Committed by Martí Bolívar
Browse files

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: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent 7f021998
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -419,6 +419,12 @@ static int websocket_interal_disconnect(struct websocket_context *ctx)

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

	ret = websocket_send_msg(ctx->sock, NULL, 0, WEBSOCKET_OPCODE_CLOSE,
				 true, true, SYS_FOREVER_MS);
	if (ret < 0) {
		NET_ERR("[%p] Failed to send close message (err %d).", ctx, ret);
	}

	ret = close(ctx->real_sock);

	websocket_context_unref(ctx);