bungle / lua-resty-session

Session library for OpenResty – flexible and secure
BSD 2-Clause "Simplified" License
320 stars 111 forks source link

attempt to send data on a closed socket #96

Closed notdodo closed 4 years ago

notdodo commented 4 years ago

Hello,

since the new release (3.2) I get the following error during the openidc authenticate function:

[error] 6#0: *8 attempt to send data on a closed socket: u:0000000000000000, c:0000000000000000, ft:0 eof:0, client: 172.26.0.1, server: , request: "GET /test HTTP/1.1", host: "172.26.0.1"

I'm using Redis to cache the session. The issue is not on the openidc library since using the version 3.1 the error is not present.

bungle commented 4 years ago

@notdodo, thank you for reporting.

bungle commented 4 years ago

@notdodo can you share your session config?

notdodo commented 4 years ago

Sure:

set $session_storage             redis;
set $session_redis_prefix        sessions;
set $session_redis_host          container-id-cache;
set $session_redis_port          6379;
set $session_redis_uselocking    on;
set $session_redis_spinlockwait  150;  # (in milliseconds)
set $session_redis_maxlockwait   30;   # (in seconds)
set $session_redis_pool_timeout  1000; # (in milliseconds)
set $session_redis_pool_size     10;
set $session_cookie_lifetime     3600;
bungle commented 4 years ago

@notdodo thank you sir!

bungle commented 4 years ago

@notdodo hmm... I could get this error when I point $session_redis_host to something that does not exists.

bungle commented 4 years ago

Or even localhost.

notdodo commented 4 years ago

The authentication flow works because the session is stored in Redis and the host is correct (it's a container hostname). After the authenticate I'm able to read and write into Redis using the same session_redis_host variable.

bungle commented 4 years ago

@notdodo thanks! I'll look into it.

bungle commented 4 years ago

@notdodo does it work if you comment out this: https://github.com/bungle/lua-resty-session/issues/96 Aka: Change:

redis:set_timeouts(connect_timeout,  send_timeout, read_timeout)

To:

--redis:set_timeouts(connect_timeout,  send_timeout, read_timeout)
bungle commented 4 years ago

@notdodo have you btw. updated redis to 6? It could be that this only triggers in some cases, which is strange. I have started seeing Connection refused errors too.

notdodo commented 4 years ago

Hi,

Redis container is 5.0.8

If I comment line 190 (redis:set_timeouts) in redis.lua the error is not shown.

bungle commented 4 years ago

@notdodo,

I also found out about this: https://github.com/openresty/lua-resty-redis/issues/178#issuecomment-558975126

Which on my machine leads to connection refused too,

bungle commented 4 years ago

@notdodo, I have released 3.3. Let me know if that helps? Please reopen, if you still have same issue.

notdodo commented 4 years ago

@bungle Thank you for the support and the quick fix. The error is gone