Hello!
On Mon, May 26, 2014 at 4:38 PM, Vladislav Manchev wrote:
> This does not work though even if I pass the websocket object as a parameter
> to the ngx.timer.at callback. Same goes for the Redis connection (it would
> be nice to reuse the current connection instead of initiating a new one),
> but I don't care much about that as I'm using a pool.
>
No, never pass any cosocket objects (including the websocket ones) to
the timer handler! Because the cosocket object is strictly bound to
the request creating it while the timer callback is detached from the
request creating the timer. Using the cosocket object out of the
boundary the creating request will yield the "bad request" error.
Also, never use a recurring timer chain with 0 timeout, because you're
essentially running a hot tight infinite loop here, which does no good
by exhausting the CPU resources
BTW, the timer callback is never never run in a separate Lua VM, even
when lua_code_cache is turned off :)
Regards,
-agentzh