moul/gotty-client

WARN[0000] Unhandled protocol message: 510

EthraZa opened this issue · 7 comments

Can't connect to server:

$ gotty-client -D https://user:pass@domain:8080
DEBU[0000] Fetching auth token auth-token: "https://domain:8080/auth_token.js" 
DEBU[0000] Auth-token: "user:pass"           
DEBU[0000] Connecting to websocket: "wss://domain:8080/ws" 
DEBU[0000] Sending arguments and auth-token             
DEBU[0000] Sending ping                                 
DEBU[0000] Unhandled protocol message: json pref: /bin/bash@subdom.domain 
WARN[0000] Unhandled protocol message: 510              
DEBU[0025] readLoop suicide                             
DEBU[0025] termsizeLoop died                            
DEBU[0025] writeLoop died                               
DEBU[0025] Client.Loop() exiting

$ gotty-client -v
gotty-client version 1.6.1

Trying out old binary version because of #91 and because there is no newer released binaries.

I'm suffering similar problem.
(And also I failed to run latest version with go get command so I just run go run on source code =>

gotty-client (master) $ pwd
/home/eub/go/src/github.com/moul/gotty-client/cmd/gotty-client
gotty-client (master) $ go run main.go -D http://****

)

I tried to print out the error in the writeLoop.
And I found interrupted system call message.

$ go run main.go -D http://****
DEBU[0000] Fetching auth token auth-token: "http://****/auth_token.js" 
DEBU[0000] Auth-token: "****"                   
DEBU[0000] Connecting to websocket: "ws://****/ws" 
DEBU[0000] Sending arguments and auth-token             
DEBU[0000] Sending ping                                 
DEBU[0000] Unhandled protocol message: json pref: {}    
$ interrupted system call
DEBU[0000] writeLoop suicide                            
DEBU[0000] termsizeLoop died                            
DEBU[0000] readLoop died                                
DEBU[0000] Client.Loop() exiting

I just ignore EINTR and the connection is not disconnected.

gotty-client.go

import (
        "crypto/tls"
        "encoding/base64"
        "encoding/json"
        "fmt"
        "io"
        "io/ioutil"
        "net/http"
        "net/url"
        "os"
        "regexp"
+        "syscall"
        "strings"
        "sync"
        "time"

        "github.com/containerd/console"
        "github.com/creack/goselect"
        "github.com/gorilla/websocket"
        "github.com/sirupsen/logrus"
)

...
...
func (c *Client) writeLoop(wg *sync.WaitGroup) poisonReason {
        defer wg.Done()
        fname := "writeLoop"

        buff := make([]byte, 128)

        rdfs := &goselect.FDSet{}
        reader := io.ReadCloser(os.Stdin)

        pr := NewEscapeProxy(reader, c.EscapeKeys)
        defer reader.Close()

        for {
                select {
                case <-c.poison:
                        /* Somebody poisoned the well; die */
                        return die(fname, c.poison)
                default:
                }

                rdfs.Zero()
                rdfs.Set(reader.(exposeFd).Fd())
                err := goselect.Select(1, rdfs, nil, nil, 50*time.Millisecond)
                if err != nil {
-                         return openPoison(fname, c.poison)
+                        fmt.Println(err)
+                        if err != syscall.EINTR {
+                                return openPoison(fname, c.poison)
+                        }
                }

But I don't think it is right solution.

GO111MODULE=on go get github.com/moul/gotty-client/cmd/gotty-client

@moul
How about using RetrySelect() instead of Select?

func (c *Client) writeLoop(wg *sync.WaitGroup) poisonReason {
...
...
-               err := goselect.Select(1, rdfs, nil, nil, 50*time.Millisecond)
+               err := goselect.RetrySelect(1, rdfs, nil, nil, 50*time.Millisecond, 3, 50*time.Millisecond)

creack/goselect#3

I think this interrupted system call happen after golang/go#38033.

go1.13.15 => no interrupted system call
go1.14.11 => interrupted system call error found
go1.15.4 => interrupted system call error found

I think this issue is different from the issue reported by @EthraZa

moul commented

I will release a new version today (#103); can you give a new try?

The current problem is that it's difficult to identify issues with versions that vary from an install to another:

  • gotty version (v1 or v2)
  • golang version used to build gotty
  • gotty-client version
  • golang version and method used to build gotty-client

Hi.

gotty-client --skip-tls-verify -D https://user:pass@domain:8080

DEBU[0000] Fetching auth token auth-token: "https://user:pass@domain:8080/auth_token.js" 
DEBU[0000] Auth-token: "user:pass"           
DEBU[0000] Connecting to websocket: "wss://domain:8080/ws" 
DEBU[0000] Sending arguments and auth-token             
DEBU[0000] Sending ping                                 
DEBU[0000] Unhandled protocol message: json pref: /bin/bash@domain 
WARN[0000] Unhandled protocol message: 510              
DEBU[0016] readLoop suicide                             
DEBU[0016] termsizeLoop died                            
DEBU[0016] writeLoop died                               
DEBU[0016] Client.Loop() exiting

gotty-client --v2 --skip-tls-verify -D https://user:pass@domain:8080

DEBU[0000] Fetching auth token auth-token: "https://user:pass@domain:8080/auth_token.js" 
DEBU[0000] Auth-token: "user:pass"           
DEBU[0000] Connecting to websocket: "wss://domain:8080/ws" 
DEBU[0000] Sending arguments and auth-token             
DEBU[0000] Sending ping                                 
DEBU[0000] Unhandled protocol message: autoreconnect: 510 
user@domain:~$ uname -a
Linux domain 5.4.77-flatcar #1 SMP Wed Nov 18 17:29:43 -00 2020 x86_64 GNU/Linux

It worked fine with --v2 switch. The new binaries helped a lot.
Thank you.