sock:settimeout(1000) -- one second timeout local bytes, err = sock:send(request)
两个问题:
1. 发送成功,只需要判断bytes吗? (怎么确定发送成功) 会不会出现部分发送成功的现象
2. 如果发送失败,会有哪些err信息呢,官网并没有给出
ps: openresty新手,
业务:发送日志,如果发送失败,把发送失败的日志信息写到一个文件中,并返回失败信息
官方链接 https://github.com/openresty/lua-nginx-module#tcpsocksend代码: sock:settimeout(1000) -- one second timeout local bytes, err = sock:send(request)两个问题:1. 发送成功,只需要判断bytes吗? (怎么确定发送成功) 会不会出现部分发送成功的现象2. 如果发送失败,会有哪些err信息呢,官网并没有给出ps: openresty新手, 业务:发送日志,如果发送失败,把发送失败的日志信息写到一个文件中,并返回失败信息
nil
On Sunday, January 8, 2017 at 11:14:55 AM UTC+8, xiaoyao Wu wrote:官方链接 https://github.com/openresty/lua-nginx-module#tcpsocksend代码: sock:settimeout(1000) -- one second timeout local bytes, err = sock:send(request)两个问题:1. 发送成功,只需要判断bytes吗? (怎么确定发送成功) 会不会出现部分发送成功的现象2. 如果发送失败,会有哪些err信息呢,官网并没有给出ps: openresty新手, 业务:发送日志,如果发送失败,把发送失败的日志信息写到一个文件中,并返回失败信息可以看ngx_http_lua_socket_tcp_send这个函数1. 如果成功的话会,返回值是非nil2. 如果是比较严重的错误,会直接lua_error,这个会导致协程结束3. 如果其他的会返回nil, err_msg(eg:nil, "timeout") --