lua-resty-http icon indicating copy to clipboard operation
lua-resty-http copied to clipboard

set_keepalive returns err “unread data in buffer”

Open legdonkey opened this issue 6 years ago • 8 comments

i have a odd issue,i use res:read_body to read all the response body,then use set_keepalive.but its returns error “unread data in buffer”. I try to use res:read_trailers() after res:read_body,but it seams does not work.

legdonkey avatar Jan 17 '18 06:01 legdonkey

Same for me.

danielBreitlauch avatar Mar 09 '18 12:03 danielBreitlauch

same error happens when I use request_uri.

shuoqingding avatar Mar 22 '18 05:03 shuoqingding

Actually for me the issue is resolved. It was showing this bc connections with timeouts where kept alive instead of closed. After closing every connection that had a timeout the buffers were fine.

danielBreitlauch avatar Mar 23 '18 09:03 danielBreitlauch

Same here.

sshniro avatar Apr 15 '20 08:04 sshniro

Same here, but I found the root cause in my case. It is because the value of HTTP header Content-Length in the response is smaller than the actual content length, and I resolve this by closing the connection when set_keepalive fails.

VeryCrazyDog avatar Apr 20 '20 07:04 VeryCrazyDog

Yes, if you have unread data still on the wire then something seems incorrect with that response (bad Content-Length for example), or you stopped reading prematurely for some other reason. The connection will be in a state which is not safe to reuse.

pintsized avatar Apr 20 '20 15:04 pintsized

Hi There,

I've found an issue when the returned result is null with content length of 4. It is easy to reproduce. Seems like the body is not detected properly and then the keepalive fails because there is still data on the wire.. Can someone help in this?

Roycohen avatar Dec 09 '20 11:12 Roycohen

Sure, are you able to post a minimal example that would demonstrate the problem?

pintsized avatar Dec 09 '20 21:12 pintsized