【问题标题】:How to connect to a Gremlin Websocket in Go?如何在 Go 中连接到 Gremlin Websocket?
【发布时间】:2017-11-03 16:26:29
【问题描述】:

我正在尝试连接到应该在端口 8182 ([INFO] GremlinServer$1 - Channel started at port 8182) 上运行的 Gremlin

当我连接到:ws://127.0.0.1:8182 我得到响应:

2017/11/03 17:20:04 ERROR: database with the name 'gremlin' gave an error when connecting: websocket: bad handshake.

Gremlin 服务器响应:

[WARN] HttpGremlinEndpointHandler - Invalid request - responding with 400 Bad Request and no gremlin script supplied

我在 Go 中使用 Gorilla Websocket 进行连接:

gremlinGrpcAddress := fmt.Sprintf("ws://%s:%d/", f.config.Host, f.config.Port)

var dialer *websocket.Dialer

clientConn, _, err := dialer.Dial(gremlinGrpcAddress, nil)
if err != nil {
    return err
}

f.client = clientConn

更新:
连接到echo.websocket.org 有效,所以不知何故它在 Gremlin 服务器中。

【问题讨论】:

  • 您是否查看过任何可用的 Go gremlin 客户端库,无论是导入还是作为如何编写客户端的示例?
  • 嗨@Adrian,是的,我正在查看github.com/go-gremlin/gremlin,但由于它没有得到维护,我正在创建自己的网络套接字连接器。
  • PS:添加更新
  • 还有github.com/qasaur/gremgo,看起来更完整。
  • 嗯,与 Gremgo 相同的错误。它不断返回bad handshake...

标签: go websocket gremlin gremlin-server


【解决方案1】:

答案在于配置 YAML 文件。

需要的是正确的通道器。

好:

channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer

【讨论】:

【解决方案2】:

连接到ws://localhost:8182/gremlin 而不是ws://localhost:8182。在 Apache TinkerPop documentation 和 go-gremlin README 中有几个对它的引用。

【讨论】:

    猜你喜欢
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 2019-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多