From 1a0ce7af3a5ab38df45616fbb85959e4039394f3 Mon Sep 17 00:00:00 2001 From: Gunther Schulz Date: Sun, 22 Nov 2020 13:21:39 +0100 Subject: [PATCH] fix incorrect setting of high water mark Socket settings need to be set before connecting to the socket Also, increase high water mark --- Experts/JsonAPI.mq5 | 34 ++++++++++++++++----------------- Indicators/JsonAPIIndicator.mq5 | 14 ++++++-------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/Experts/JsonAPI.mq5 b/Experts/JsonAPI.mq5 index a54b7d2..9e90d96 100644 --- a/Experts/JsonAPI.mq5 +++ b/Experts/JsonAPI.mq5 @@ -113,6 +113,23 @@ ControlErrors mControl; //+------------------------------------------------------------------+ bool BindSockets() { + sysSocket.setLinger(1000); + dataSocket.setLinger(1000); + liveSocket.setLinger(1000); + streamSocket.setLinger(1000); + indicatorDataSocket.setLinger(1000); + chartDataSocket.setLinger(1000); + chartIndicatorDataSocket.setLinger(1000); + +// Number of messages to buffer in RAM. + sysSocket.setSendHighWaterMark(1000); + dataSocket.setSendHighWaterMark(1000); + liveSocket.setSendHighWaterMark(1000); + streamSocket.setSendHighWaterMark(1000); + indicatorDataSocket.setSendHighWaterMark(1000); + chartDataSocket.setReceiveHighWaterMark(1000); // TODO confirm settings + chartIndicatorDataSocket.setReceiveHighWaterMark(1000); + bool result = false; result = sysSocket.bind(StringFormat("tcp://%s:%d", HOST,SYS_PORT)); if(result == false) @@ -178,23 +195,6 @@ bool BindSockets() Print("Bound 'JsonAPIIndicator Data' socket on port ", CHART_INDICATOR_DATA_PORT); } - sysSocket.setLinger(1000); - dataSocket.setLinger(1000); - liveSocket.setLinger(1000); - streamSocket.setLinger(1000); - indicatorDataSocket.setLinger(1000); - chartDataSocket.setLinger(1000); - chartIndicatorDataSocket.setLinger(1000); - -// Number of messages to buffer in RAM. - sysSocket.setSendHighWaterMark(1); - dataSocket.setSendHighWaterMark(5); - liveSocket.setSendHighWaterMark(1); - streamSocket.setSendHighWaterMark(50); - indicatorDataSocket.setSendHighWaterMark(5); - chartDataSocket.setReceiveHighWaterMark(1); // TODO confirm settings - chartIndicatorDataSocket.setReceiveHighWaterMark(1); - return result; } diff --git a/Indicators/JsonAPIIndicator.mq5 b/Indicators/JsonAPIIndicator.mq5 index d9f64c0..fade209 100644 --- a/Indicators/JsonAPIIndicator.mq5 +++ b/Indicators/JsonAPIIndicator.mq5 @@ -46,7 +46,12 @@ int activeBufferCount = 0; int OnInit() { - +// TODO subscribe only to own IndicatorId topic +// Subscribe to all topics + chartSubscriptionSocket.setSubscribe(""); + chartSubscriptionSocket.setLinger(1000); +// Number of messages to buffer in RAM. + chartSubscriptionSocket.setReceiveHighWaterMark(1000); // TODO confirm settings bool result = chartSubscriptionSocket.connect(StringFormat("tcp://%s:%d", HOST, CHART_SUB_PORT)); if(result == false) { @@ -55,13 +60,6 @@ int OnInit() else { Print("Accepting Chart Indicator data on port ", CHART_SUB_PORT); - // TODO subscribe only to own IndicatorId topic - // Subscribe to all topics - chartSubscriptionSocket.setSubscribe(""); - //chartSubscriptionSocket.setLinger(1000); - chartSubscriptionSocket.setLinger(10000); - // Number of messages to buffer in RAM. - chartSubscriptionSocket.setReceiveHighWaterMark(5); // TODO confirm settings }