diff --git a/include/common.h b/include/common.h
index 2c8d014b12..f0b0909654 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1119,7 +1119,7 @@ void	zbx_setproctitle(const char *fmt, ...) __zbx_attr_format_printf(1, 2);
 #define ZBX_JAN_2038		2145916800
 #define ZBX_JAN_1970_IN_SEC	2208988800.0	/* 1970 - 1900 in seconds */
 
-#define ZBX_MAX_RECV_DATA_SIZE	(1 * ZBX_GIBIBYTE)
+#define ZBX_MAX_RECV_DATA_SIZE	(__UINT64_C(8) * ZBX_GIBIBYTE)
 
 /* max length of base64 data */
 #define ZBX_MAX_B64_LEN		(16 * ZBX_KIBIBYTE)
diff --git a/include/comms.h b/include/comms.h
index f1e5f8c5a7..904f22c0f4 100644
--- a/include/comms.h
+++ b/include/comms.h
@@ -113,6 +113,7 @@ int	zbx_tcp_connect(zbx_socket_t *s, const char *source_ip, const char *ip, unsi
 
 #define ZBX_TCP_PROTOCOL		0x01
 #define ZBX_TCP_COMPRESS		0x02
+#define ZBX_TCP_LARGE			0x04
 
 #define ZBX_TCP_SEC_UNENCRYPTED		1		/* do not use encryption with this socket */
 #define ZBX_TCP_SEC_TLS_PSK		2		/* use TLS with pre-shared key (PSK) with this socket */
diff --git a/src/libs/zbxcomms/comms.c b/src/libs/zbxcomms/comms.c
index ce73a1e3ec..ce28eb72de 100644
--- a/src/libs/zbxcomms/comms.c
+++ b/src/libs/zbxcomms/comms.c
@@ -814,11 +814,11 @@ int	zbx_tcp_send_ext(zbx_socket_t *s, const char *data, size_t len, unsigned cha
 {
 #define ZBX_TLS_MAX_REC_LEN	16384
 
-	ssize_t		bytes_sent, written = 0;
-	size_t		send_bytes, offset, send_len = len, reserved = 0;
-	int		ret = SUCCEED;
-	char		*compressed_data = NULL;
-	zbx_uint32_t	len32_le;
+	ssize_t			bytes_sent, written = 0;
+	size_t			send_bytes, offset, send_len = len, reserved = 0;
+	int			ret = SUCCEED;
+	char			*compressed_data = NULL;
+	const zbx_uint64_t	max_uint32 = ~(zbx_uint32_t)0;
 
 	if (0 != timeout)
 		zbx_socket_timeout_set(s, timeout);
@@ -846,15 +846,35 @@ int	zbx_tcp_send_ext(zbx_socket_t *s, const char *data, size_t len, unsigned cha
 		memcpy(header_buf, ZBX_TCP_HEADER_DATA, ZBX_CONST_STRLEN(ZBX_TCP_HEADER_DATA));
 		offset = ZBX_CONST_STRLEN(ZBX_TCP_HEADER_DATA);
 
+		if (max_uint32 <= len)
+			flags |= ZBX_TCP_LARGE;
+
 		header_buf[offset++] = flags;
 
-		len32_le = zbx_htole_uint32((zbx_uint32_t)send_len);
-		memcpy(header_buf + offset, &len32_le, sizeof(len32_le));
-		offset += sizeof(len32_le);
+		if (0 != (flags & ZBX_TCP_LARGE))
+		{
+			zbx_uint64_t	len64_le;
+
+			len64_le = zbx_htole_uint64((zbx_uint64_t)send_len);
+			memcpy(header_buf + offset, &len64_le, sizeof(len64_le));
+			offset += sizeof(len64_le);
 
-		len32_le = zbx_htole_uint32((zbx_uint32_t)reserved);
-		memcpy(header_buf + offset, &len32_le, sizeof(len32_le));
-		offset += sizeof(len32_le);
+			len64_le = zbx_htole_uint64((zbx_uint64_t)reserved);
+			memcpy(header_buf + offset, &len64_le, sizeof(len64_le));
+			offset += sizeof(len64_le);
+		}
+		else
+		{
+			zbx_uint32_t	len32_le;
+
+			len32_le = zbx_htole_uint32((zbx_uint32_t)send_len);
+			memcpy(header_buf + offset, &len32_le, sizeof(len32_le));
+			offset += sizeof(len32_le);
+
+			len32_le = zbx_htole_uint32((zbx_uint32_t)reserved);
+			memcpy(header_buf + offset, &len32_le, sizeof(len32_le));
+			offset += sizeof(len32_le);
+		}
 
 		take_bytes = MIN(send_len, ZBX_TLS_MAX_REC_LEN - offset);
 		memcpy(header_buf + offset, data, take_bytes);
@@ -1709,7 +1729,7 @@ ssize_t	zbx_tcp_recv_ext(zbx_socket_t *s, int timeout)
 
 	ssize_t		nbytes;
 	size_t		buf_dyn_bytes = 0, buf_stat_bytes = 0, offset = 0;
-	zbx_uint32_t	expected_len = 16 * ZBX_MEBIBYTE, reserved = 0;
+	zbx_uint64_t	expected_len = 16 * ZBX_MEBIBYTE, reserved = 0;
 	unsigned char	expect = ZBX_TCP_EXPECT_HEADER;
 	int		protocol_version;
 
@@ -1769,7 +1789,7 @@ ssize_t	zbx_tcp_recv_ext(zbx_socket_t *s, int timeout)
 			protocol_version = s->buf_stat[ZBX_TCP_HEADER_LEN];
 
 			if (0 == (protocol_version & ZBX_TCP_PROTOCOL) ||
-					protocol_version > (ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS))
+					protocol_version > (ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS | ZBX_TCP_LARGE))
 			{
 				/* invalid protocol version, abort receiving */
 				break;
@@ -1781,16 +1801,36 @@ ssize_t	zbx_tcp_recv_ext(zbx_socket_t *s, int timeout)
 
 		if (ZBX_TCP_EXPECT_LENGTH == expect)
 		{
-			if (offset + 2 * sizeof(zbx_uint32_t) > buf_stat_bytes)
-				continue;
+			if (0 != (protocol_version & ZBX_TCP_LARGE))
+			{
+				zbx_uint64_t	len64_le;
 
-			memcpy(&expected_len, s->buf_stat + offset, sizeof(zbx_uint32_t));
-			offset += sizeof(zbx_uint32_t);
-			expected_len = zbx_letoh_uint32(expected_len);
+				if (offset + 2 * sizeof(len64_le) > buf_stat_bytes)
+					continue;
+
+				memcpy(&len64_le, s->buf_stat + offset, sizeof(len64_le));
+				offset += sizeof(len64_le);
+				expected_len = zbx_letoh_uint64(len64_le);
+
+				memcpy(&len64_le, s->buf_stat + offset, sizeof(len64_le));
+				offset += sizeof(len64_le);
+				reserved = zbx_letoh_uint64(len64_le);
+			}
+			else
+			{
+				zbx_uint32_t	len32_le;
+
+				if (offset + 2 * sizeof(len32_le) > buf_stat_bytes)
+					continue;
 
-			memcpy(&reserved, s->buf_stat + offset, sizeof(zbx_uint32_t));
-			offset += sizeof(zbx_uint32_t);
-			reserved = zbx_letoh_uint32(reserved);
+				memcpy(&len32_le, s->buf_stat + offset, sizeof(len32_le));
+				offset += sizeof(len32_le);
+				expected_len = zbx_letoh_uint32(len32_le);
+
+				memcpy(&len32_le, s->buf_stat + offset, sizeof(len32_le));
+				offset += sizeof(len32_le);
+				reserved = zbx_letoh_uint32(len32_le);
+			}
 
 			if (ZBX_MAX_RECV_DATA_SIZE < expected_len)
 			{
diff --git a/src/libs/zbxjson/json.c b/src/libs/zbxjson/json.c
index 029bbfb1b4..4f51190f12 100644
--- a/src/libs/zbxjson/json.c
+++ b/src/libs/zbxjson/json.c
@@ -583,8 +583,8 @@ static const char	*__zbx_json_rbracket(const char *p)
  ******************************************************************************/
 int	zbx_json_open(const char *buffer, struct zbx_json_parse *jp)
 {
-	char	*error = NULL;
-	int	len;
+	char		*error = NULL;
+	zbx_uint64_t	len;
 
 	SKIP_WHITESPACE(buffer);
 
diff --git a/src/libs/zbxjson/json_parser.c b/src/libs/zbxjson/json_parser.c
index 08e150f21f..a15ac42011 100644
--- a/src/libs/zbxjson/json_parser.c
+++ b/src/libs/zbxjson/json_parser.c
@@ -25,7 +25,7 @@
 
 #include "log.h"
 
-static int	json_parse_object(const char *start, char **error);
+static zbx_uint64_t	json_parse_object(const char *start, char **error);
 
 /******************************************************************************
  *                                                                            *
@@ -72,7 +72,7 @@ static int	json_error(const char *message, const char *json_buffer, char **error
  * Author: Andris Zeila                                                       *
  *                                                                            *
  ******************************************************************************/
-static int	json_parse_string(const char *start, char **error)
+static zbx_uint64_t	json_parse_string(const char *start, char **error)
 {
 	const char	*ptr = start;
 
@@ -130,7 +130,7 @@ static int	json_parse_string(const char *start, char **error)
 		ptr++;
 	}
 
-	return (int)(ptr - start) + 1;
+	return ptr - start + 1;
 }
 
 /******************************************************************************
@@ -149,10 +149,10 @@ static int	json_parse_string(const char *start, char **error)
  * Author: Andris Zeila                                                       *
  *                                                                            *
  ******************************************************************************/
-static int	json_parse_array(const char *start, char **error)
+static zbx_uint64_t	json_parse_array(const char *start, char **error)
 {
 	const char	*ptr = start;
-	int		len;
+	zbx_uint64_t	len;
 
 	ptr++;
 	SKIP_WHITESPACE(ptr);
@@ -179,7 +179,7 @@ static int	json_parse_array(const char *start, char **error)
 			return json_error("invalid array format, expected closing character ']'", ptr, error);
 	}
 
-	return (int)(ptr - start) + 1;
+	return ptr - start + 1;
 }
 
 /******************************************************************************
@@ -198,7 +198,7 @@ static int	json_parse_array(const char *start, char **error)
  * Author: Andris Zeila                                                       *
  *                                                                            *
  ******************************************************************************/
-static int	json_parse_number(const char *start, char **error)
+static zbx_uint64_t	json_parse_number(const char *start, char **error)
 {
 	const char	*ptr = start;
 	char		first_digit;
@@ -254,7 +254,7 @@ static int	json_parse_number(const char *start, char **error)
 		}
 	}
 
-	return (int)(ptr - start);
+	return ptr - start;
 }
 
 /******************************************************************************
@@ -277,7 +277,7 @@ static int	json_parse_number(const char *start, char **error)
  *           false.                                                           *
  *                                                                            *
  ******************************************************************************/
-static int	json_parse_literal(const char *start, const char *text, char **error)
+static zbx_uint64_t	json_parse_literal(const char *start, const char *text, char **error)
 {
 	const char	*ptr = start;
 
@@ -289,7 +289,7 @@ static int	json_parse_literal(const char *start, const char *text, char **error)
 		text++;
 	}
 
-	return (int)(ptr - start);
+	return ptr - start;
 }
 
 /******************************************************************************
@@ -308,10 +308,10 @@ static int	json_parse_literal(const char *start, const char *text, char **error)
  * Author: Andris Zeila                                                       *
  *                                                                            *
  ******************************************************************************/
-int	json_parse_value(const char *start, char **error)
+zbx_uint64_t	json_parse_value(const char *start, char **error)
 {
 	const char	*ptr = start;
-	int		len;
+	zbx_uint64_t	len;
 
 	SKIP_WHITESPACE(ptr);
 
@@ -361,7 +361,7 @@ int	json_parse_value(const char *start, char **error)
 			return json_error("invalid JSON object value starting character", ptr, error);
 	}
 
-	return (int)(ptr - start) + len;
+	return (ptr - start) + len;
 }
 
 /******************************************************************************
@@ -380,10 +380,10 @@ int	json_parse_value(const char *start, char **error)
  * Author: Andris Zeila                                                       *
  *                                                                            *
  ******************************************************************************/
-static int	json_parse_object(const char *start, char **error)
+static zbx_uint64_t	json_parse_object(const char *start, char **error)
 {
 	const char	*ptr = start;
-	int		len;
+	zbx_uint64_t	len;
 
 	/* parse object name */
 	SKIP_WHITESPACE(ptr);
@@ -430,7 +430,7 @@ static int	json_parse_object(const char *start, char **error)
 			return json_error("invalid object format, expected closing character '}'", ptr, error);
 	}
 
-	return (int)(ptr - start) + 1;
+	return ptr - start + 1;
 }
 
 /******************************************************************************
@@ -451,9 +451,9 @@ static int	json_parse_object(const char *start, char **error)
  * Author: Andris Zeila                                                       *
  *                                                                            *
  ******************************************************************************/
-int	zbx_json_validate(const char *start, char **error)
+zbx_uint64_t	zbx_json_validate(const char *start, char **error)
 {
-	int	len;
+	zbx_uint64_t	len;
 
 	/* parse object name */
 	SKIP_WHITESPACE(start);
diff --git a/src/libs/zbxjson/json_parser.h b/src/libs/zbxjson/json_parser.h
index ed4fb117b2..ea79b9efab 100644
--- a/src/libs/zbxjson/json_parser.h
+++ b/src/libs/zbxjson/json_parser.h
@@ -20,8 +20,8 @@
 #ifndef ZABBIX_JSON_PARSER_H
 #define ZABBIX_JSON_PARSER_H
 
-int	zbx_json_validate(const char *start, char **error);
+zbx_uint64_t	zbx_json_validate(const char *start, char **error);
 
-int	json_parse_value(const char *start, char **error);
+zbx_uint64_t	json_parse_value(const char *start, char **error);
 
 #endif
