如何连接到 Go 中的 Gremlin Websocket?
How to connect to a Gremlin Websocket in Go?
我正在尝试连接到 Gremlin,它应该是 运行 端口 8182 ([INFO] GremlinServer - Channel started at port 8182
)
当我连接到: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 服务器中。
连接到 ws://localhost:8182/gremlin
而不是 ws://localhost:8182
。在 Apache TinkerPop documentation and the go-gremlin README.
中有多个对它的引用
答案就在配置 YAML 文件中。
需要的是正确的通道化器。
好:
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
我正在尝试连接到 Gremlin,它应该是 运行 端口 8182 ([INFO] GremlinServer - Channel started at port 8182
)
当我连接到: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 服务器中。
连接到 ws://localhost:8182/gremlin
而不是 ws://localhost:8182
。在 Apache TinkerPop documentation and the go-gremlin README.
答案就在配置 YAML 文件中。
需要的是正确的通道化器。
好:
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer