ctgpf opened a new issue #4529:
URL: https://github.com/apache/apisix/issues/4529
### Issue description
Hello all,
I'm trying to use this simple lua function in serverless plugin:
```
"plugins": {
"serverless-post-function": {
"disable": false,
"functions": [
"return function() ngx.log(ngx.ERR, \"BEGIN:\"); os.execute('curl
http://127.0.0.1:9180/apisix/admin/plugins/list -H \"X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1\"'); ngx.log(ngx.ERR, \"END:\"); end"
],
"phase": "body_filter"
}
}
```
But when testing, the curl command hangs indefinitely and never ends...
Here are some debug information:
> **# strace -p <curl_PID>**
> poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0
(Timeout)
> poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0
(Timeout)
> ...
> poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0
(Timeout)
> poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0
(Timeout)
So the curl is waiting for the fd 4 to become ready, but timeout.
> **# ls -l /proc/<curl_PID>/fd**
> 4 -> socket:[91241]
> **# lsof -p <PID> |grep 91241**
> TCP localhost:49198->localhost:9180 (ESTABLISHED)
So the socket is opened and the tcpdump shows that the GET method is indeed
sent. But no response from the REST Admin API.
For information, os.execute('curl
http://127.0.0.1:9180/apisix/admin/plugins/list -H \"X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1\" **&**'); with the '&' at the end works, but
I want to wait until curl finishes instead of launching in background.
Setting the timeout option to curl, os.execute('curl **-m 3** http://...')
triggers the timeout in apisix error.log:
> curl: (28) Operation timed out after 3001 milliseconds with 0 out of -1
bytes received
I have tried other methods, but they failed too:
- wget instead of curl
- io.popen() instead of os.execute()
Can someone please know how to make it work?
### Environment
Request help without environment information will be ignored or closed.
* apisix version (cmd: `apisix version`): 2.6
* OS (cmd: `uname -a`): Linux localhost.localdomain
3.10.0-1160.31.1.el7.x86_64 #1 SMP Thu Jun 10 13:32:12 UTC 2021 x86_64 x86_64
x86_64 GNU/Linux
* OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): nginx
version: openresty/1.19.3.2
* etcd version, if have (cmd: run `curl
http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
"etcd_version":"3.5.0"
* apisix-dashboard version, if have: 2.7
* luarocks version, if the issue is about installation (cmd: `luarocks
--version`): 3.4.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]