[2.8.x] Log websocket communication problems + handle special Netty case #11519
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(I am looking into this because a premium sponsor asked me because they run into problem regarding websockets.)
When a client closes a websocket connection, it's possible it sends an optional status code. Those status codes are defined here: https://www.rfc-editor.org/rfc/rfc6455#section-7.4
Now, if a client sends a status code not defined in that list (or one that is reserved for other purposes) akka-http does not care but let's the close status code pass through into the application code, so it does not distinguish between valid and invalid status codes.
Netty however is very strict, it does not pass a
play.api.http.websocket.CloseMessage
on into application code. As a consequence an app handlingCloseMessage
will never receive it, even though Netty closes the connection and actually throws an error. However, right now that error is swallowed by Play, it's impossible to see what's going on. So this pull requests adds a warning if a problem occurs. That at least gives developers a indication that something wrong happened.Update: In the second commit of this PR i decided to not just log a warning, but to also handle the Netty close status code problem explicitly by passing the
CloseMessage
with the "invalid" Status code down to the app. I think this makes a lot of sense, devs should be able to react even on invalid status codes, like they can for akka-http. It's a bit tricky right now since the information is only available in the error message. However even if Netty changes that string, at least the code would fall back and log the warning, so it's at least visible somehwere: