Giter Site home page Giter Site logo

Panic with large body sizes about sish HOT 6 CLOSED

bibo38 avatar bibo38 commented on June 15, 2024
Panic with large body sizes

from sish.

Comments (6)

antoniomika avatar antoniomika commented on June 15, 2024

You can disable the idle connection logic by setting idle-connection=false either in the command line or in your sish config.

from sish.

bibo38 avatar bibo38 commented on June 15, 2024

Thanks, but this issue shows that the idle connection logic is implemented wrong. The documentation says Duration to wait for activity before closing a connection for all reads and writes (default 5s), but in the example the connection is closed after 5 seconds regardless of activity

from sish.

antoniomika avatar antoniomika commented on June 15, 2024

The idle timeout exists for both sides of the tunnel. If one side of the tunnel (the writer) doesn't receive any messages, the connection is considered dead. This is currently implemented with golang's connection deadlines, which doesn't really have a way to apply deadlines differently (single deadline which includes read or write as extending the deadline). This is the expected behavior of how this is implemented.

We could maybe make sish smarter by looking for when a deadline occurs and having retry logic in if the other side of the connection has still not hit its deadline, but this feature can just as easily be disabled and timeouts handled by the ping timeout instead

from sish.

antoniomika avatar antoniomika commented on June 15, 2024

I'm gonna open a PR with https://github.com/antoniomika/sish/blob/main/utils/conn.go#L181 changed to just call SetDeadline instead of the individual read or write deadlines. This would theoretically push both deadlines continuously as either read or write is called. Mind helping me test out those changes @bibo38 ?

from sish.

bibo38 avatar bibo38 commented on June 15, 2024

Thanks. Pushing both deadlines solves my problem 👍

Here is the diff that worked for my downloading file usecase:

diff --git a/utils/conn.go b/utils/conn.go
index 45b1df1..6927c94 100644
--- a/utils/conn.go
+++ b/utils/conn.go
@@ -184,7 +184,7 @@ type IdleTimeoutConn struct {
 
 // Read is needed to implement the reader part.
 func (i IdleTimeoutConn) Read(buf []byte) (int, error) {
-       err := i.Conn.SetReadDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
+       err := i.Conn.SetDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
        if err != nil {
                return 0, err
        }
@@ -194,7 +194,7 @@ func (i IdleTimeoutConn) Read(buf []byte) (int, error) {
 
 // Write is needed to implement the writer part.
 func (i IdleTimeoutConn) Write(buf []byte) (int, error) {
-       err := i.Conn.SetWriteDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
+       err := i.Conn.SetDeadline(time.Now().Add(viper.GetDuration("idle-connection-timeout")))
        if err != nil {
                return 0, err
        }

Handling the errors is probably also a good idea to print meaningful status errors like The [HTTP/SSH/TCP] connection with X was longer than Y idle and therefore terminated, instead of a panic (which let's you think it's a bug in sish).

from sish.

antoniomika avatar antoniomika commented on June 15, 2024

Cool! Appreciate you went through building and testing. I'll make a PR and get a version patched!

from sish.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.