diff options
-rw-r--r-- | src/daq/nginx-lua/s5-nginx.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/daq/nginx-lua/s5-nginx.lua b/src/daq/nginx-lua/s5-nginx.lua index c38b692..6559e95 100644 --- a/src/daq/nginx-lua/s5-nginx.lua +++ b/src/daq/nginx-lua/s5-nginx.lua @@ -130,9 +130,17 @@ local send_data = function(sock, starttime) '"quality": "' .. s.quality .. '" }, ' json = json .. '"data": ' .. get_data_streamer(s.content, s.format, s.quality) json = json .. '}\n' - local ok, err = sock:send(json) - if not ok then - return nil, err + while true do + -- TODO: this should probably be done inside a seperate writer thread + local ok, err = sock:send(json) + if not ok then + if err ~= "resource temporarily unavailable" then + return nil, err + end + ngx.sleep(0.02) + else + break + end end end return true |