nebula-go报错: Authentication fails, Invalid data length

一个简单的查询实现,和nebula-go的README中示例基本一致
执行到client.Connect()函数时报错:Authentication fails, Invalid data length
尝试调整过client.Connect()中的用户名、密码输入参数,都没有成功
希望能够得到帮助

package main

import (
  "log"

  nebula "github.com/vesoft-inc/nebula-go"
)

func main() {
  client, err := nebula.NewClient("127.0.0.1:3699")
  if err != nil {
    log.Fatal(err)
  }

  if err = client.Connect("", ""); err != nil {
    log.Fatal(err)
  }
  defer client.Disconnect()

  resp, err := client.Execute("SHOW HOSTS;")
  if err != nil {
    log.Fatal(err)
  }

  if nebula.IsError(resp) {
    log.Printf("ErrorCode: %v, ErrorMsg: %s", resp.GetErrorCode(), resp.GetErrorMsg())
  }
}

nebula-graphd.conf相关配置如下

########## authorization ##########
# Enable authorization
--enable_authorize=false

########## Authentication ##########
# User login authentication type, password for nebula authentication, ldap for ldap authentication, cloud for cloud authentication
--auth_type=password

–enable_authorize=false
false要改成true啊。。。。你认证功能没有开吧?

也不行…
很奇怪的是,我跑nebula-go项目中的client_test.go是可以的。但是在上面的代码里,用同样的ip, port, username, password,会报"Authentication fails, Invalid data length"

First of all my apologies for writing in English, I am afraid that Google translate to Chinese may garble what I am about to say. I have similar error to what Arthritis encountered. I have Nebula installed and working (1.0) under docker-compose, can access it via command-line client and Nebula studio. However when I try to connect via Go client (same code as above) I have same error.


I went to nebula-docker-compose_graphd_1 and edited the nebula-graphd.conf (switched --enable_authorise to false and true) - this had an effect on command-line client. When --enable_authorize=true it refused to connect with default username/password

when set to false command line client connected without username/password no problem at all.
However this has no effect at all on Go client. The error remains. Could you kindly direct me, what am I doing wrong? yet again, sorry for writing in foreign language. Any help is much appreciated.

1 个赞

Hi, I have found out why “Invalid data length” problem happens.

It’s because the fbthrift version on your client is not compatible with nebula.

You can check the “go.mod” file in nebula-go project, it need “require github.com/facebook/fbthrift v0.0.0-20190922225929-2f9839604e25”


And for the second problem about failed to authenticate “user”, try “-u root -p nebula” instead of “-u user -p password”

2 个赞

when enable_authorize is false,
There is no difference between a and b “-u root -p nebula” and “-u user -p password

hi, arthritis and all

many thanks for your help. I have checked go.mod and the version was right. I have created another user with admin privileges on nba. Explicitly enabled the password authentication in nebula-graphd.conf. I ran the code in the debugger and nailed it, where the error appears.


Tomorrow I will set up a breakpoint there and will step in to find out exactly where it appears.
Thanks a million for your help.

2 个赞
1 个赞

Dear yee, you are spot on. So, what I did now to correct this error above.

  1. create the empty folder outside GOPATH
  2. generated mod file, as per your link
    https://github.com/vesoft-inc/nebula-go/pull/34/files/e450cf6135393795ae20ebffbb30fb7864f623c3
  3. first tried with command-line (build/run) it worked - no fatal errors
  4. then created the new GoLand (it is SDK on the pic above in this thread) project in the same folder I have just created
  5. SDK imported go.mod
  6. run - success, not annoying error

Dear all, thanks a million for your help - looks like I came over this hurdle. Sure there will be more, but at least I know where to ask.

4 个赞

ah, if you need, we have an international forum:https://discuss.nebula-graph.io/, which has more English details and a better site visit speed for other places out of China. :wink:

1 个赞