outline-server icon indicating copy to clipboard operation
outline-server copied to clipboard

Websockets traffic not stable over Outline (possible keepalive issue)

Open mountaindude opened this issue 8 years ago • 76 comments

I have Outline set up nicely on a small dedicated Google GCP server. There are GCP firewall rules allowing any traffic coming into the Outline server to be sent to other servers in the same GCP network.

I access services running on those other GCP servers, via the Outline server, from Chrome on my Macbook. These services use websockets to send data in real-time from the server to my web browser. Works fine for a while, but after a minute or two the websocket connection drops, and the browser page has to be reloaded. Repeat again and again.

Seems Outline is just not (yet) very stable wrt websockets... Or could I be suffering from some other phenomena?

I have tried upgrading the Outline server to a larger one, in case it was overloaded and caused packet drops - nothing changed.

mountaindude avatar Apr 10 '18 20:04 mountaindude

Thanks for the report. This is the first time we hear about this issue. How can we reproduce the problem so we can investigate? Do you see the same issue with https://websocket.org/echo.html ? If not, is the website you are experiencing this issue with public?

fortuna avatar May 01 '18 16:05 fortuna

I'll test against that site too, to see if I can reproduce the issue. I am on a 250 MBit fiber connection, low latency etc. So it's not a matter of a poor connection.

I noticed the issue when connecting to a Qlik Sense (business intelligence tool/platform) cluster running on a couple of Google cloud servers (running Windows Server 2016), using Outline on a Linux box as VPN gateway into the GCP cluster. The servers are thus not publicly available.

For what it's worth, I also tried spinning up Algo VPN on an indentical Linux box in that same GCP cluster, works a treat even when I have really stressed the connection/servers.

So... not sure what I can recommend for reproducing the issue.. If you have some ideas on what I should look out for I am happy to do so and report back, but I fully understand that's a pretty poor way of debugging issues..

mountaindude avatar May 01 '18 17:05 mountaindude

I think we have a suspicion: we probably need to set up TCP keep-alive in either the Outline server or client. We'll investigate more.

fortuna avatar May 01 '18 19:05 fortuna

@alalamav @bemasc : It seems shadowsocks-libev doesn't enable keep-alive, except in the "redir" mode, which we don't use: https://github.com/shadowsocks/shadowsocks-libev/search?utf8=%E2%9C%93&q=alive&type=

I don't know if there's a reason for that. It might be a nice change to upstream.

fortuna avatar May 03 '18 04:05 fortuna

@madeye is there a reason for shadowsocks-libev to not set up tcp keep-alive in regular client or server mode?

fortuna avatar May 03 '18 04:05 fortuna

Enlarge the default timeout to 600 seconds. Otherwise, the connection will be killed automatically.

Also make sure both server and client's timeouts are set to be larger than 600s.

madeye avatar May 03 '18 08:05 madeye

@fortuna I just wanted to check in to see if there is something I can contribute with. I am not much of a VPN developer, but happy to test stuff if needed.

Also, I realised that the ws timeout seems to arrive pretty close to 60 sec after the session is established. Could be a conincidence, or there is a 60 sec timeout somewhere that should be (much) longer?

mountaindude avatar May 14 '18 20:05 mountaindude

Maybe it could be useful: http://coryklein.com/tcp/2015/11/25/custom-configuration-of-tcp-socket-keep-alive-timeouts.html

igor-ramazanov avatar May 21 '18 01:05 igor-ramazanov

@madeye would a keep-alive be enough? I'd think it would prevent the timeout. Why is a larger timeout better?

fortuna avatar Jun 13 '18 16:06 fortuna

I experience similar issue with SSH and MySQL connections. :(

Matvey-Kuk avatar Jul 30 '18 19:07 Matvey-Kuk

I have the same issue too. It keeps dropping SSH connection after a minute.

tolgahanbozkurt avatar Aug 11 '18 15:08 tolgahanbozkurt

We're looking into this issue. @madeye why do we need a timeout at all? I'm thinking about using something like INT_MAX. Couldn't disconnections of idle connections be driven by the client or server?

For the record, I tried the Outline client with a server that has keep alive enabled (outline-ss-server) and I still see disconnections. I believe due to the ss-libev timeout.

fortuna avatar Aug 22 '18 15:08 fortuna

Timeout is a parameter you can tune for both client and server.

For a high load server, a small timeout would improve the overall performance a lot.

madeye avatar Aug 23 '18 01:08 madeye

How do I tune timeout parameter? I couldn't find any config file or something.

tolgahanbozkurt avatar Aug 23 '18 07:08 tolgahanbozkurt

@madeye in my case timeout is a show-stopper for users. They actively use SSH, Ansible, MySQL and other tools which are sensitive for connection reliability. I'm not sure what is the philosophy of the project but it could be nice to make it a universal tool for everyone 😃

Matvey-Kuk avatar Aug 23 '18 11:08 Matvey-Kuk

@tlghnb @Matvey-Kuk: Outline sets the timeout parameter on the ss-local and ss-server calls. (BTW, @madeye is the owner of shadowsocks-libev. He doesn't work for Outline.)

We currently use the default of 60s in both the server and the client. Users can't toggle that, but we intend to make that change. It's still unclear what number we should use.

On the client side (ss-local), I don't see a good reason for the timeout, so we'll probably set it quite high (INT_MAX?). On the server side, my understanding is that it's useful against DDoS attacks or rogue clients. @madeye recommended 10m, but I don't know if that's enough for SSH and other applications. @madeye : To make sure I understand: the timeout is for idle connections right? If there's activity the connections will last past the timeout?

fortuna avatar Aug 23 '18 16:08 fortuna

@fortuna about timeout value I can share my case: users expect connection without timeouts at all =( They open SSH connections and return to them from time to time during working day.

Matvey-Kuk avatar Aug 24 '18 14:08 Matvey-Kuk

@fortuna: I am experiencing the same issue with SSH timeouts. Your understanding is correct that it is only for idle connections (i.e. ones where the user is not sending or receiving any data). I have also validated that the issue continues to occur after the client update was installed on my Mac with the ss-local timeout changed to INT_MAX.

Would it make sense to allow the timeout to be configurable in the outline manager application? I think a default of 1 hour or something reasonably high might be good, but in some cases (like mine), I would prefer it to be more than that (probably 2 hours or more). Even a fix of one hour would really help in my situation.

caljorden avatar Sep 06 '18 04:09 caljorden

Thanks for the feedback @caljorden

Even though we increased the timeout on the client-side, we haven't fixed the server yet. We are moving to use outline-ss-server, which won't have a timeout (the connection closing will be driven by the endpoints only).

If you'd like to check if outline-ss-server fixes for you, you can run that server on your own, or access this prototype server I have running in London: https://s3.amazonaws.com/outline-vpn/invite.html#ss%3A%2F%2FY2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTp5bXJnZ2ZLZWFXR3U%3D%40167.99.202.119%3A61434%2F%3Foutline%3D1

If you try, please let me know how it goes. Keep in mind I'll revoke the key without notice.

fortuna avatar Sep 06 '18 05:09 fortuna

@fortuna: I just verified that with your London server the SSH timeout was not occurring for me. I waited almost 5 minutes without any activity and did not see it disconnect. Thus, the new outline-ss-server fixes the issue. Thank you for your work on this! Any idea when the outline-ss-server will be rolled out to outline manager configured servers?

caljorden avatar Sep 07 '18 15:09 caljorden