0

我正在尝试打开 ws 连接,但出现错误:

val openConnection = exec( ws("Connect -> WS").wsName("user").connect("wss://socket.develop.test.com?access_token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9"))

然后,我得到:

09:49:53.343 [DEBUG] i.g.h.c.i.DefaultHttpClient - Installing SslHandler for wss://socket.develop.test.com?access_token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9
09:49:53.381 [DEBUG] i.n.h.s.u.InsecureTrustManagerFactory - Accepting a server certificate: CN=Kubernetes Ingress Controller Fake Certificate, O=Acme Co
09:49:53.418 [DEBUG] i.n.h.c.h.w.WebSocketClientHandshaker13 - WebSocket version 13 client handshake key: YndmXwIGgZseWyRlmXBoyw==, expected response: H2YGNn6p+DyLyudnc1JCluHjj7E=
09:49:53.419 [DEBUG] i.g.h.c.i.WebSocketHandler - ctx.write msg=DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1, content: EmptyByteBufBE)
GET ?access_token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9
HTTP/1.1
    accept: */*
    upgrade: websocket
    connection: upgrade
    sec-websocket-key: YndmXwIGgZseWyRlmXBoyw==
    host: socket.develop.test.com
    origin: https://socket.develop.test.com
    sec-websocket-version: 13
    09:49:53.423 [DEBUG] i.n.h.s.SslHandler - [id: 0xfa53644a, L:/192.168.150.134:54082 - R:socket.develop.test.com/78.47.16.48:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
    09:49:53.450 [DEBUG] i.g.h.c.i.WebSocketHandler - Read msg=HttpObjectAggregator$AggregatedFullHttpResponse(decodeResult: success, version: HTTP/1.1, content: CompositeByteBuf(ridx: 0, widx: 163, cap: 163, components=1))
    HTTP/1.1 400 Bad Request
    Server: openresty/1.15.8.1
    Date: Tue, 10 Mar 2020 06:49:53 GMT
    Content-Type: text/html
    Content-Length: 163
    Connection: close
    09:49:53.452 [DEBUG] i.g.h.c.i.WebSocketHandler - Crash
    io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Invalid handshake response getStatus: 400 Bad Request
        at io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13.verify(WebSocketClientHandshaker13.java:267)

在 gatling.conf 中,我还设置了:

enableSni = false
useOpenSsl = false
enableHostnameVerification = false

如果我尝试打开与 SmartWebsocketClient 之类的任何 WS 客户端的连接 - 一切都很好,但是通过 gatling 我无法打开连接。有什么想法可以解决吗?

4

2 回答 2

1

wss://domain?access_token...不是有效的 URL。路径组件必须以 a/而不是 a开头?。这意味着该请求是无效的,这可以解释 的响应400 Bad Request

URL 必须至少是wss://domain/?access_token...(即,在/之前?),但 URL 的其余部分也可能是服务器意外的。请检查服务器的实际要求。

于 2020-03-10T07:50:49.177 回答
1

这是 Netty 中的一个错误,当路径为空时,它无法正确计算 WebSocket 握手请求 url。我刚刚贡献了一个补丁:https ://github.com/netty/netty/pull/10095 。Gatling 中的兄弟姐妹问题:https ://github.com/gatling/gatling/issues/3876

于 2020-03-10T09:31:42.260 回答