HTTP: Websocket doen't handle correctly server closing connection
See original GitHub issueThe context :
- a client establish a websocket connection to a server
- the client sends bytes (multiple times) and waits for server response data
- the server returns response data and close the websocket connection right after
When the connection is closed, I get this error:
i.g.h.a.w.f.WsActor - unhandled event WebSocketCrashed(io.gatling.http.client.impl.HttpAppHandler$1: Premature close,...) in state Crashed
If the server returns only data, and the client close the websocket connection, its working fine.
I tried with Gatling 3.0.2-SNAPSHOT
(which contains this fix https://github.com/gatling/gatling/issues/3630)
Sample scenario:
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class ServerCloseSimulation extends Simulation {
private val bytes: Array[Byte] = ???
private val httpProtocol = http.wsBaseUrl("ws://localhost:9000")
private val scn = scenario("ServerCloseSimulation")
.exec(ws("Connect").connect("/"))
.foreach(bytes.grouped(2048).toSeq, "packet") {
exec(ws("Send bytes").sendBytes("${packet}")).pause(60.millis)
}
.pause(10.seconds) // fails here
.exec(ws("Close").close)
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to Close a WebSocket (Correctly) - Forty Years of Code
A client WebSocket that starts the closing handshake fails to transition to the Closed state when the server acknowledges the initial Close ......
Read more >Closing WebSocket correctly (HTML5, Javascript)
It seems insane that it doesn't close the connection. The WebSocket variable is wiped out on page reload, so why would the connection...
Read more >WebSocket.close() - Web APIs - MDN Web Docs
close () method closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED , this method does nothing....
Read more >Troubleshooting connection issues | Socket.IO
You are trying to reach a plain WebSocket server · The server is not reachable · The client is not compatible with the...
Read more >Websocket connection does not terminate even when client ...
For the same, I wrote the below server code and simple client (executed in Chrome browser console). It works, but when I call...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s the simulation I ran against your sample:
Then, I wonder if your problem is that you’re not increasing
wsMaxReconnects
.Cool, thanks! Travelling this week so I might only be able to have a look next week.