Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to send to Sentry: connection reset by peer #30

Closed
kupson opened this issue Jul 2, 2019 · 1 comment
Closed

Failed to send to Sentry: connection reset by peer #30

kupson opened this issue Jul 2, 2019 · 1 comment

Comments

@kupson
Copy link

kupson commented Jul 2, 2019

The event is POSTed successfully to local Sentry instance but the ravel-lua logs following error:

2019/07/01 12:24:41 [error] 10#10: *10 recv() failed (104: Connection reset by peer), client: 127.0.0.1, server: _, request: "POST /xxx HTTP/1.1", host: "127.0.0.1:7000"
2019/07/01 12:24:41 [error] 10#10: *10 [lua] ngx.lua:32: errlog(): raven-lua failure: Failed to send to Sentry: connection reset by peer {"timestamp":"2019-07-01T12:24:41","message":"xxx",...} , client: 127.0.0.1, server: _, request: "POST /xxx HTTP/1.1", host: "127.0.0.1:7000"

Looks like it's caused by connection to server being closed by Sentry (the module sent Connection: close header in the request) in a way that generates TCP RST packets - SO_LINGER on with zero linger time followed by close().

Example packets captured by tcpdump:

12:37:28.518716 IP 172.20.6.171.34090 > 172.20.2.181.8000: Flags [S], seq 2319457555, win 27560, options [mss 1378,sackOK,TS val 922459539 ecr 0,nop,wscale 7], length 0
12:37:28.518745 IP 172.20.2.181.8000 > 172.20.6.171.34090: Flags [S.], seq 2641603589, ack 2319457556, win 27320, options [mss 1378,sackOK,TS val 119696926 ecr 922459539,nop,wscale 7], length 0
12:37:28.519025 IP 172.20.6.171.34090 > 172.20.2.181.8000: Flags [.], ack 1, win 216, options [nop,nop,TS val 922459540 ecr 119696926], length 0 
12:37:28.519078 IP 172.20.6.171.34090 > 172.20.2.181.8000: Flags [.], seq 1:1367, ack 1, win 216, options [nop,nop,TS val 922459540 ecr 119696926], length 1366
12:37:28.519111 IP 172.20.2.181.8000 > 172.20.6.171.34090: Flags [.], ack 1367, win 235, options [nop,nop,TS val 119696926 ecr 922459540], length 0
12:37:28.519216 IP 172.20.6.171.34090 > 172.20.2.181.8000: Flags [.], seq 1367:2733, ack 1, win 216, options [nop,nop,TS val 922459540 ecr 119696926], length 1366
12:37:28.519227 IP 172.20.2.181.8000 > 172.20.6.171.34090: Flags [.], ack 2733, win 257, options [nop,nop,TS val 119696926 ecr 922459540], length 0
12:37:28.519322 IP 172.20.6.171.34090 > 172.20.2.181.8000: Flags [P.], seq 2733:3812, ack 1, win 216, options [nop,nop,TS val 922459540 ecr 119696926], length 1079
12:37:28.519328 IP 172.20.2.181.8000 > 172.20.6.171.34090: Flags [.], ack 3812, win 278, options [nop,nop,TS val 119696926 ecr 922459540], length 0
12:37:28.543914 IP 172.20.2.181.8000 > 172.20.6.171.34090: Flags [P.], seq 1:367, ack 3812, win 278, options [nop,nop,TS val 119696951 ecr 922459540], length 366
12:37:28.544222 IP 172.20.6.171.34090 > 172.20.2.181.8000: Flags [.], ack 367, win 224, options [nop,nop,TS val 922459565 ecr 119696951], length 0
12:37:28.544677 IP 172.20.2.181.8000 > 172.20.6.171.34090: Flags [R.], seq 367, ack 3812, win 278, options [nop,nop,TS val 119696952 ecr 922459565], length 0 

The sock:receive('*a') function returns error on such connections.

kupson added a commit to kupson/raven-lua that referenced this issue Jul 2, 2019
Fixes cloudflare#30

Reads all data from the buffers before closing it so it will play nice with
keep-alive (https://github.com/openresty/lua-nginx-module#tcpsocksetkeepalive).

Keep-alive is not implemented yet -- let's be nice to it thought.
@jdesgats
Copy link
Contributor

Hi,

Thank you for your report and sorry for the slow response. I fixed that issue using the regular ngx sender. While I'm not fundamentally opposed to a lua-resty-http backend, it adds an extra (optional) dependency but also both proposals duplicate quite a bit of code (to handle the asynchronous sending when sockets are not available) and don't pass the lint checks properly for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants