Custom plugin use lua-resty-http

– handler.lua
local BasePlugin = require “kong.plugins.base_plugin”
– local client = require “src.httpclient”
local XngAuthHandler = BasePlugin:extend()
local timeout = 500
local host = “172.0.0.1”
local port = 8922
local path = “/token/v1/api/valid”
XngAuthHandler.VERSION = “1.0.0”
XngAuthHandler.PRIORITY = 10
local http = require “resty.http”

function XngAuthHandler:access(config)
local httpc = http.new()
httpc:set_timeout(timeout)
local ok, err = httpc:connect(host, port)
if not ok then
kong.log.err("failed to connect to " … host … “:” … tostring(port) … ": " … err)
end

local res, err = httpc:request({
method = “POST”,
path = path,
headers = kong.request.get_headers(),
})
if not res then
kong.log.err("failed request to " … host … “:” … tostring(port) … ": " … err)
return
end
local response_body = res:read_body()
local ok, err = httpc:set_keepalive()
if not ok then
kong.log.err("failed keepalive for ", host, “:”, tostring(port), ": ", err)
end
end

return XngAuthHandler

above is my code, I implement a custom plugin to request my server.
when I send a request with body by postman, it’s tell me timeout .



but I send a request with body is non , it’s normal

why? please help me, thanks