Lua Server Side Events client cosocket driver for OpenResty / ngx_lua.
This library is still under active development and is considered production ready.
lua_package_path "/path/to/lua-resty-sse/lib/?.lua;;";
server {
location /simpleinterface {
resolver 8.8.8.8; # Google's open DNS server for an example
content_by_lua_block {
local sse = require "resty.sse"
local conn, err = sse.new()
if not conn then
ngx.say("failed to get connection: ", err)
end
local res, err = conn:request_uri("http://some-pub-sub-server.com/subscriber")
if not res then
ngx.say("failed to request: ", err)
return
end
while true
local event, err = conn:receive()
if err then ngx.say("got an error: ", err) end
if event then ngx.say("got an event: ", event) end
end
}
}
}
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO
TODO