Nevermind, I already see a problem with that approach: socat might not
split the messages as I want, so when writing
{"message":"hello world"}
I might end up sending 2 messages:
1: {"message"
2: :"hello world"}
On Wed, Jul 16, 2014 at 9:26 AM, Christophe-Marie Duquesne <c...@chmd.fr> wrote:
> Thank you very much for your answer!
>
> Unfortunately, I don't think I can easily install the latest openresty
> bundle. My development has to target debian wheezy, and I should avoid
> installing a custom version (custom as opposed to officially
> packaged). So unless there is no other solution, I am constrained to
> only use standard debian packages .
>
> I am thinking about a workaround, using socat. Basically, I would run
> externally e.g.
> socat PIPE:/var/run/nginx.pipe UDP-SENDTO:192.168.1.2:8145
> and from the lua, I would write data to /var/run/nginx.pipe
> (My use case requires to continuously write data to the same address)
>
> Do you think it is a bad idea? Can do that and still be non blocking?
>
> Regards,
> Christophe-Marie
>
> On Tue, Jul 15, 2014 at 9:19 PM, Yichun Zhang (agentzh)
> <age...@gmail.com> wrote:
>> Hello!
>>
>> On Tue, Jul 15, 2014 at 8:16 AM, Christophe-Marie Duquesne wrote:
>>>
>>> - attempt to index field 'udp' (a nil value)
>>> - attempt to index field 'timer' (a nil value)
>>>
>>
>> Such errors are usually a clear sign for an old ngx_lua module version
>> that lacks the corresponding API functions.
>>
>>> If I understand the doc, both of these api calls should be available
>>> in the access_by_lua* context.
>>>
>>
>> As long as your ngx_lua version also qualifies.
>>
>>> I just checked my version of nginx, and I got:
>>> nginx version: nginx/1.2.1
>>>
>>> The wiki says ngx.socket.udp was added in v0.5.7 r, and ngx.timer in v0.8.0.
>>>
>>
>> The wiki you're referring to should be ngx_lua module's version. So
>> the version numbers here like "v0.5.7" and "v0.8.0" are ngx_lua
>> module's version instead of the nginx core's.
>>
>> Check the version of your ngx_lua module instead.
>>
>> BTW, to prevent such problems, it is recommended to always use the
>> latest version of the OpenResty bundle:
>>
>> http://openresty.org/#Download
>>
>> Regards,
>> -agentzh.