(apologies if there’s a better place to post peer-review requests; LMK)
The url in the code is to a local service which keeps the connection open, sending JSON objects as “chunked” HTTP data.
< HTTP/1.1 200 OK
< content-type: application/json
< transfer-encoding: chunked
(ie: the first obj comes, then X seconds later, another obj, etc, etc, forever). I did not write the service; it’s black box; can’t change it.
This snippet is part of a larger monitoring app. The first need here is to read and parse the JSON objects. The second need is that if the HTTP chunked-stream is closed/interrupted, it needs to be recreated. The third need is that if it doesn’t receive data after X seconds, assume something is wrong and reconnect.
So far in my testing, this is working great, but I just wanted to check with the community as I’m a novice golang developer. I feel like I’m not properly checking for “HTTP closed/network io issues” and that if dec.More is false, assume “some error” and retry. Keepalive doesn’t do anything since this is not multi-request/bidirectional like WSS.
Thanks for taking the time to read and comment!