@@ -57,6 +57,7 @@ module.exports = function (RED) {
5757 if ( config . thing !== "" && config . property !== "" ) {
5858 this . arduinoRestClient = await connectionManager . getClientHttp ( connectionConfig ) ;
5959 if ( this . arduinoRestClient ) {
60+ this . arduinoRestClient . openConnections ++ ;
6061 this . thing = config . thing ;
6162 this . propertyId = config . property ;
6263 this . propertyName = config . name ;
@@ -73,8 +74,8 @@ module.exports = function (RED) {
7374 this . status ( { fill : "red" , shape : "dot" , text : "Error setting value" } ) ;
7475 }
7576 } ) ;
76- this . on ( 'close' , function ( ) {
77- connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) ;
77+ this . on ( 'close' , function ( done ) {
78+ connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) . then ( ( ) => { done ( ) ; } ) ;
7879 } ) ;
7980 } else {
8081 this . status ( { fill : "red" , shape : "ring" , text : "Connection Error" } ) ;
@@ -100,6 +101,7 @@ module.exports = function (RED) {
100101 try {
101102 this . arduinoRestClient = await connectionManager . getClientHttp ( connectionConfig ) ;
102103 if ( this . arduinoRestClient ) {
104+ this . arduinoRestClient . openConnections ++ ;
103105 if ( config . thing !== "" && config . property !== "" ) {
104106 this . thing = config . thing ;
105107 this . propertyId = config . property ;
@@ -135,8 +137,8 @@ module.exports = function (RED) {
135137 }
136138 } ) ;
137139
138- this . on ( 'close' , function ( ) {
139- connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) ;
140+ this . on ( 'close' , function ( done ) {
141+ connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) . then ( ( ) => { done ( ) ; } ) ;
140142 } ) ;
141143 }
142144 } else {
@@ -162,15 +164,16 @@ module.exports = function (RED) {
162164 try {
163165 this . arduinoRestClient = await connectionManager . getClientHttp ( connectionConfig ) ;
164166 if ( this . arduinoRestClient ) {
167+ this . arduinoRestClient . openConnections ++ ;
165168 if ( config . thing !== "" && config . property !== "" ) {
166169 this . thing = config . thing ;
167170 this . propertyId = config . property ;
168171 this . propertyName = config . name ;
169172 const pollTime = this . timeWindowCount * this . timeWindowUnit ;
170173 if ( pollTime !== null && pollTime !== "" && pollTime !== undefined && Number . isInteger ( parseInt ( pollTime ) ) && parseInt ( pollTime ) !== 0 ) {
171174 this . poll ( connectionConfig , pollTime ) ;
172- this . on ( 'close' , function ( ) {
173- connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) ;
175+ this . on ( 'close' , function ( done ) {
176+ connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) . then ( ( ) => { done ( ) ; } ) ;
174177 if ( this . pollTimeoutPoll )
175178 clearTimeout ( this . pollTimeoutPoll ) ;
176179
@@ -224,6 +227,7 @@ module.exports = function (RED) {
224227 if ( config . thing !== "" && config . property !== "" ) {
225228 this . arduinoRestClient = await connectionManager . getClientHttp ( connectionConfig ) ;
226229 if ( this . arduinoRestClient ) {
230+ this . arduinoRestClient . openConnections ++ ;
227231 this . thing = config . thing ;
228232 this . propertyId = config . property ;
229233 this . propertyName = config . name ;
@@ -243,8 +247,8 @@ module.exports = function (RED) {
243247 else
244248 this . status ( { } ) ;
245249 } ) ;
246- this . on ( 'close' , function ( ) {
247- connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) ;
250+ this . on ( 'close' , function ( done ) {
251+ connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) . then ( ( ) => { done ( ) ; } ) ;
248252 } ) ;
249253 } else {
250254 this . status ( { fill : "red" , shape : "ring" , text : "Connection Error" } ) ;
0 commit comments