http builder buffer
I currently have a http builder set up to send post data to a server. Recently there was an issue where the server was rejecting the password and the mango device was receiving a 401 response.
Is there a way using the http builder to keep unsent post messages in a buffer and then to automatically send them when the server issue is resolved?
@robmalone yes, the Script data source and Meta data points retain state while they are enabled. This means you could create an array that exists while the source/point is running to store failed messages. On each run you would check the array and if not empty then try to resend the messages.
Just remember if you stop the point or data source that array will go away. If you need more resilience you could attempt to store the messages, that will be much more complex but is possible.
The messages are actually already being saved.
The meta data point is an alphanumeric point pulling values from other modbus points and sending them together in one message.
I'm afraid I'm not a programmer. Would you be able to help with the script?
@MattFox I don't suppose you can help me with this please?
@robmalone pm sent
One way I kept state in my various scripting data sources was to JSON.stringify the persistent state into an alphanumeric point on the scripting data source. Then if
if ( typeof( state ) === 'undefined' ) state = JSON.parse( state_context_point.value );
Of course, that would require doing this on any state change (or every script execution):
state_context_point.set( JSON.stringify( state ) );
But it gets the added benefit that now the state of your script is accessible to either review or fetch into other logic or dashboards or whatnot.
@dillfunlap exactly what we did.
And if you're who I think you are. Good to see you.
Thanks Matt :). Nice to see some familiar faces here!