diff --git a/res/res_http_websocket.c b/res/res_http_websocket.c
index 9e5c60d831f142abf85c5298bca5b41a6ec712c0..7a2552e78f1ba92e375f318a626d9d7005cf662f 100644
--- a/res/res_http_websocket.c
+++ b/res/res_http_websocket.c
@@ -351,7 +351,7 @@ int AST_OPTIONAL_API_NAME(ast_websocket_write)(struct ast_websocket *session, en
 	if (length == 126) {
 		put_unaligned_uint16(&frame[2], htons(actual_length));
 	} else if (length == 127) {
-		put_unaligned_uint64(&frame[2], htobe64(actual_length));
+		put_unaligned_uint64(&frame[2], htonll(actual_length));
 	}
 
 	ao2_lock(session);