diff --git a/include/comms.h b/include/comms.h
index f1e5f8c5a7..ed75aee43b 100644
--- a/include/comms.h
+++ b/include/comms.h
@@ -123,12 +123,13 @@ int	zbx_tcp_connect(zbx_socket_t *s, const char *source_ip, const char *ip, unsi
 
 const char	*zbx_tcp_connection_type_name(unsigned int type);
 
-#define zbx_tcp_send(s, d)				zbx_tcp_send_ext((s), (d), strlen(d), ZBX_TCP_PROTOCOL, 0)
-#define zbx_tcp_send_to(s, d, timeout)			zbx_tcp_send_ext((s), (d), strlen(d), ZBX_TCP_PROTOCOL, timeout)
-#define zbx_tcp_send_bytes_to(s, d, len, timeout)	zbx_tcp_send_ext((s), (d), len, ZBX_TCP_PROTOCOL, timeout)
-#define zbx_tcp_send_raw(s, d)				zbx_tcp_send_ext((s), (d), strlen(d), 0, 0)
+#define zbx_tcp_send(s, d)				zbx_tcp_send_ext((s), (d), strlen(d), 0, ZBX_TCP_PROTOCOL, 0)
+#define zbx_tcp_send_to(s, d, timeout)			zbx_tcp_send_ext((s), (d), strlen(d), 0, ZBX_TCP_PROTOCOL, timeout)
+#define zbx_tcp_send_bytes_to(s, d, len, timeout)	zbx_tcp_send_ext((s), (d), len, 0, ZBX_TCP_PROTOCOL, timeout)
+#define zbx_tcp_send_raw(s, d)				zbx_tcp_send_ext((s), (d), strlen(d), 0, 0, 0)
 
-int	zbx_tcp_send_ext(zbx_socket_t *s, const char *data, size_t len, unsigned char flags, int timeout);
+int	zbx_tcp_send_ext(zbx_socket_t *s, const char *data, size_t len, size_t reserved, unsigned char flags,
+		int timeout);
 
 void	zbx_tcp_close(zbx_socket_t *s);
 
diff --git a/src/libs/zbxcomms/comms.c b/src/libs/zbxcomms/comms.c
index ce73a1e3ec..dfd4a17d74 100644
--- a/src/libs/zbxcomms/comms.c
+++ b/src/libs/zbxcomms/comms.c
@@ -810,12 +810,13 @@ static ssize_t	zbx_tcp_write(zbx_socket_t *s, const char *buf, size_t len)
 #define ZBX_TCP_HEADER_DATA	"ZBXD"
 #define ZBX_TCP_HEADER_LEN	ZBX_CONST_STRLEN(ZBX_TCP_HEADER_DATA)
 
-int	zbx_tcp_send_ext(zbx_socket_t *s, const char *data, size_t len, unsigned char flags, int timeout)
+int	zbx_tcp_send_ext(zbx_socket_t *s, const char *data, size_t len, size_t reserved, unsigned char flags,
+		int timeout)
 {
 #define ZBX_TLS_MAX_REC_LEN	16384
 
 	ssize_t		bytes_sent, written = 0;
-	size_t		send_bytes, offset, send_len = len, reserved = 0;
+	size_t		send_bytes, offset, send_len = len;
 	int		ret = SUCCEED;
 	char		*compressed_data = NULL;
 	zbx_uint32_t	len32_le;
@@ -829,18 +830,20 @@ int	zbx_tcp_send_ext(zbx_socket_t *s, const char *data, size_t len, unsigned cha
 		char	header_buf[ZBX_TLS_MAX_REC_LEN];	/* Buffer is allocated on stack with a hope that it   */
 								/* will be short-lived in CPU cache. Static buffer is */
 								/* not used on purpose.				      */
-
 		if (0 != (flags & ZBX_TCP_COMPRESS))
 		{
-			if (SUCCEED != zbx_compress(data, len, &compressed_data, &send_len))
+			if (0 == reserved)
 			{
-				zbx_set_socket_strerror("cannot compress data: %s", zbx_compress_strerror());
-				ret = FAIL;
-				goto cleanup;
-			}
+				if (SUCCEED != zbx_compress(data, len, &compressed_data, &send_len))
+				{
+					zbx_set_socket_strerror("cannot compress data: %s", zbx_compress_strerror());
+					ret = FAIL;
+					goto cleanup;
+				}
 
-			data = compressed_data;
-			reserved = len;
+				data = compressed_data;
+				reserved = len;
+			}
 		}
 
 		memcpy(header_buf, ZBX_TCP_HEADER_DATA, ZBX_CONST_STRLEN(ZBX_TCP_HEADER_DATA));
diff --git a/src/libs/zbxcommshigh/comms.c b/src/libs/zbxcommshigh/comms.c
index a59cdbaea8..8728d10184 100644
--- a/src/libs/zbxcommshigh/comms.c
+++ b/src/libs/zbxcommshigh/comms.c
@@ -66,7 +66,7 @@ int	zbx_send_response_ext(zbx_socket_t *sock, int result, const char *info, cons
 
 	zabbix_log(LOG_LEVEL_DEBUG, "%s() '%s'", __func__, json.buffer);
 
-	if (FAIL == (ret = zbx_tcp_send_ext(sock, json.buffer, strlen(json.buffer), protocol, timeout)))
+	if (FAIL == (ret = zbx_tcp_send_ext(sock, json.buffer, strlen(json.buffer), 0, protocol, timeout)))
 	{
 		zabbix_log(LOG_LEVEL_DEBUG, "Error sending result back: %s", zbx_socket_strerror());
 		ret = NETWORK_ERROR;
diff --git a/src/zabbix_proxy/servercomms.c b/src/zabbix_proxy/servercomms.c
index 63e919ce8c..f9030b8dd1 100644
--- a/src/zabbix_proxy/servercomms.c
+++ b/src/zabbix_proxy/servercomms.c
@@ -131,7 +131,7 @@ int	get_data_from_server(zbx_socket_t *sock, const char *request, char **error)
 	zbx_json_addstring(&j, "host", CONFIG_HOSTNAME, ZBX_JSON_TYPE_STRING);
 	zbx_json_addstring(&j, ZBX_PROTO_TAG_VERSION, ZABBIX_VERSION, ZBX_JSON_TYPE_STRING);
 
-	if (SUCCEED != zbx_tcp_send_ext(sock, j.buffer, strlen(j.buffer), ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS, 0))
+	if (SUCCEED != zbx_tcp_send_ext(sock, j.buffer, strlen(j.buffer), 0, ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS, 0))
 	{
 		*error = zbx_strdup(*error, zbx_socket_strerror());
 		goto exit;
@@ -170,7 +170,7 @@ int	put_data_to_server(zbx_socket_t *sock, struct zbx_json *j, char **error)
 
 	zabbix_log(LOG_LEVEL_DEBUG, "In %s() datalen:" ZBX_FS_SIZE_T, __func__, (zbx_fs_size_t)j->buffer_size);
 
-	if (SUCCEED != zbx_tcp_send_ext(sock, j->buffer, strlen(j->buffer), ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS, 0))
+	if (SUCCEED != zbx_tcp_send_ext(sock, j->buffer, strlen(j->buffer), 0, ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS, 0))
 	{
 		*error = zbx_strdup(*error, zbx_socket_strerror());
 		goto out;
diff --git a/src/zabbix_server/proxypoller/proxypoller.c b/src/zabbix_server/proxypoller/proxypoller.c
index d4907ce3e9..501627c243 100644
--- a/src/zabbix_server/proxypoller/proxypoller.c
+++ b/src/zabbix_server/proxypoller/proxypoller.c
@@ -31,6 +31,7 @@
 #include "proxy.h"
 #include "zbxcrypto.h"
 #include "../trapper/proxydata.h"
+#include "zbxcompress.h"
 
 extern unsigned char	process_type, program_type;
 extern int		server_num, process_num;
@@ -84,7 +85,8 @@ out:
 	return ret;
 }
 
-static int	send_data_to_proxy(const DC_PROXY *proxy, zbx_socket_t *sock, const char *data, size_t size)
+static int	send_data_to_proxy(const DC_PROXY *proxy, zbx_socket_t *sock, const char *data, size_t size,
+		size_t reserved)
 {
 	int	ret, flags = ZBX_TCP_PROTOCOL;
 
@@ -93,7 +95,7 @@ static int	send_data_to_proxy(const DC_PROXY *proxy, zbx_socket_t *sock, const c
 	if (0 != proxy->auto_compress)
 		flags |= ZBX_TCP_COMPRESS;
 
-	if (FAIL == (ret = zbx_tcp_send_ext(sock, data, size, flags, 0)))
+	if (FAIL == (ret = zbx_tcp_send_ext(sock, data, size, reserved, flags, 0)))
 	{
 		zabbix_log(LOG_LEVEL_ERR, "cannot send data to proxy \"%s\": %s", proxy->host, zbx_socket_strerror());
 
@@ -171,7 +173,7 @@ static int	get_data_from_proxy(DC_PROXY *proxy, const char *request, char **data
 		if (NULL != ts)
 			zbx_timespec(ts);
 
-		if (SUCCEED == (ret = send_data_to_proxy(proxy, &s, j.buffer, j.buffer_size)))
+		if (SUCCEED == (ret = send_data_to_proxy(proxy, &s, j.buffer, j.buffer_size, 0)))
 		{
 			if (SUCCEED == (ret = recv_data_from_proxy(proxy, &s)))
 			{
@@ -229,10 +231,11 @@ static int	get_data_from_proxy(DC_PROXY *proxy, const char *request, char **data
  ******************************************************************************/
 static int	proxy_send_configuration(DC_PROXY *proxy)
 {
-	char		*error = NULL;
+	char		*error = NULL, *data = NULL;
 	int		ret;
 	zbx_socket_t	s;
 	struct zbx_json	j;
+	size_t		len, reserved;
 
 	zbx_json_init(&j, 512 * ZBX_KIBIBYTE);
 
@@ -246,16 +249,40 @@ static int	proxy_send_configuration(DC_PROXY *proxy)
 		goto out;
 	}
 
+	if (0 != proxy->auto_compress)
+	{
+		if (SUCCEED != zbx_compress(j.buffer, j.buffer_size, &data, &len))
+		{
+			zabbix_log(LOG_LEVEL_ERR,"cannot compress data: %s", zbx_compress_strerror());
+			ret = FAIL;
+			goto out;
+		}
+
+		reserved = j.buffer_size;
+		zbx_json_free(&j);	/* json buffer can be large, free as fast as possible */
+	}
+	else
+		reserved = 0;
+
 	if (SUCCEED != (ret = connect_to_proxy(proxy, &s, CONFIG_TRAPPER_TIMEOUT)))
 		goto out;
 
 	zabbix_log(LOG_LEVEL_WARNING, "sending configuration data to proxy \"%s\" at \"%s\", datalen " ZBX_FS_SIZE_T,
 			proxy->host, s.peer, (zbx_fs_size_t)j.buffer_size);
 
-	if (SUCCEED == (ret = send_data_to_proxy(proxy, &s, j.buffer, j.buffer_size)))
+	if (0 != reserved)
+	{
+		ret = send_data_to_proxy(proxy, &s, data, len, reserved);
+		zbx_free(data);		/* json buffer can be large, free as fast as possible */
+	}
+	else
 	{
+		ret = send_data_to_proxy(proxy, &s, j.buffer, j.buffer_size, reserved);
 		zbx_json_free(&j);	/* json buffer can be large, free as fast as possible */
+	}
 
+	if (SUCCEED == ret)
+	{
 		if (SUCCEED != (ret = zbx_recv_response(&s, 0, &error)))
 		{
 			zabbix_log(LOG_LEVEL_WARNING, "cannot send configuration data to proxy"
@@ -281,6 +308,7 @@ static int	proxy_send_configuration(DC_PROXY *proxy)
 
 	disconnect_proxy(&s);
 out:
+	zbx_free(data);
 	zbx_free(error);
 	zbx_json_free(&j);
 
diff --git a/src/zabbix_server/trapper/active.c b/src/zabbix_server/trapper/active.c
index 11bef06b7c..05bd3775f2 100644
--- a/src/zabbix_server/trapper/active.c
+++ b/src/zabbix_server/trapper/active.c
@@ -762,7 +762,7 @@ int	send_list_of_active_checks_json(zbx_socket_t *sock, struct zbx_json_parse *j
 
 	zabbix_log(LOG_LEVEL_DEBUG, "%s() sending [%s]", __func__, json.buffer);
 
-	if (SUCCEED != zbx_tcp_send_ext(sock, json.buffer, json.buffer_size, sock->protocol, CONFIG_TIMEOUT))
+	if (SUCCEED != zbx_tcp_send_ext(sock, json.buffer, json.buffer_size, 0, sock->protocol, CONFIG_TIMEOUT))
 		strscpy(error, zbx_socket_strerror());
 	else
 		ret = SUCCEED;
diff --git a/src/zabbix_server/trapper/proxyconfig.c b/src/zabbix_server/trapper/proxyconfig.c
index dc3c383506..3e09abb3cc 100644
--- a/src/zabbix_server/trapper/proxyconfig.c
+++ b/src/zabbix_server/trapper/proxyconfig.c
@@ -78,7 +78,7 @@ void	send_proxyconfig(zbx_socket_t *sock, struct zbx_json_parse *jp)
 			proxy.host, sock->peer, (zbx_fs_size_t)j.buffer_size);
 	zabbix_log(LOG_LEVEL_DEBUG, "%s", j.buffer);
 
-	if (SUCCEED != zbx_tcp_send_ext(sock, j.buffer, strlen(j.buffer), flags, CONFIG_TRAPPER_TIMEOUT))
+	if (SUCCEED != zbx_tcp_send_ext(sock, j.buffer, strlen(j.buffer), 0, flags, CONFIG_TRAPPER_TIMEOUT))
 	{
 		zabbix_log(LOG_LEVEL_WARNING, "cannot send configuration data to proxy \"%s\" at \"%s\": %s",
 				proxy.host, sock->peer, zbx_socket_strerror());
diff --git a/src/zabbix_server/trapper/proxydata.c b/src/zabbix_server/trapper/proxydata.c
index 1104649894..56ca2c3adc 100644
--- a/src/zabbix_server/trapper/proxydata.c
+++ b/src/zabbix_server/trapper/proxydata.c
@@ -76,7 +76,7 @@ int	zbx_send_proxy_data_response(const DC_PROXY *proxy, zbx_socket_t *sock, cons
 	if (0 != proxy->auto_compress)
 		flags |= ZBX_TCP_COMPRESS;
 
-	if (SUCCEED == (ret = zbx_tcp_send_ext(sock, json.buffer, strlen(json.buffer), flags, 0)))
+	if (SUCCEED == (ret = zbx_tcp_send_ext(sock, json.buffer, strlen(json.buffer), 0, flags, 0)))
 	{
 		if (0 != tasks.values_num)
 			zbx_tm_update_task_status(&tasks, ZBX_TM_STATUS_INPROGRESS);
@@ -194,7 +194,7 @@ out:
  ******************************************************************************/
 static int	send_data_to_server(zbx_socket_t *sock, const char *data, char **error)
 {
-	if (SUCCEED != zbx_tcp_send_ext(sock, data, strlen(data), ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS, CONFIG_TIMEOUT))
+	if (SUCCEED != zbx_tcp_send_ext(sock, data, strlen(data), 0, ZBX_TCP_PROTOCOL | ZBX_TCP_COMPRESS, CONFIG_TIMEOUT))
 	{
 		*error = zbx_strdup(*error, zbx_socket_strerror());
 		return FAIL;
