You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading from a socket, 0 bytes, it blocks until data becomes available on the socket.
I ran into this due to a compatibility issue between OpenResty and LuaSocket. The http client in use simply reads the body based on the Content-Length header, even if that is 0. This returned us timeout errors when LuaSocket was in use, but not with the OpenResty sockets.
To reproduce (using Copas for the server):
#!/usr/bin/env copas-- Save this file as "server.lua"localport=20000localaddress="127.0.0.1"localsocket=require("socket")
localserver_sock=assert(socket.bind(address, port))
localfunctionhandle_client(client_sock)
localfunctionprint(...)
_G.print(copas.getthreadname(), ...)
endprint"received connection, sending 10 bytes..."print("send results: ", client_sock:send("1234567890"))
print"sent 10 bytes, now pausing for 5 seconds..."copas.pause(5)
print("send 10 more results: ", client_sock:send("1234567890"))
print"closing"client_sock:close()
endcopas.addserver(server_sock, copas.handler(handle_client), "my_TCP_server")
print("server started on port "..port)
When reading from a socket, 0 bytes, it blocks until data becomes available on the socket.
I ran into this due to a compatibility issue between OpenResty and LuaSocket. The http client in use simply reads the body based on the
Content-Length
header, even if that is 0. This returned ustimeout
errors when LuaSocket was in use, but not with the OpenResty sockets.To reproduce (using Copas for the server):
Using openresty for the Client:
What the code does:
Here's the client output:
Note that LuaSocket also returns the time it took (OpenResty doesn't).
The text was updated successfully, but these errors were encountered: