Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select an arbitrary websocket subprotocol proposed by the client #8860

Merged
merged 4 commits into from Dec 9, 2018

Conversation

raboof
Copy link
Member

@raboof raboof commented Dec 6, 2018

Simple (on par with Netty) solution to #7895. Later we could extend our API to
allow the framework user to select a subprotocol instead.

*
* See https://github.com/playframework/playframework/issues/7895
*/
def handleWebSocket(upgrade: UpgradeToWebSocket, flow: Flow[Message, Message, _], bufferLimit: Int): HttpResponse =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should at least deprecate this. I'm not even sure this class should be considered part of the public API.

Copy link
Member

@marcospereira marcospereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raboof
Copy link
Member Author

raboof commented Dec 6, 2018

Not really AFAICS, as it seems WebSocketClient doesn't allow setting that header...

@marcospereira
Copy link
Member

I think we can change connect method to also have a headers: Seq[(String, String)] = Seq.empty and later use the value here:

val handshaker = WebSocketClientHandshakerFactory.newHandshaker(tgt, version, null, false, new DefaultHttpHeaders())

Instead of just using an empty DefaultHttpHeaders. Do you think that would be enough to then add some tests?

Copy link
Member

@marcospereira marcospereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Thank you, @raboof.

@marcospereira marcospereira merged commit 78b41e0 into master Dec 9, 2018
@marcospereira marcospereira deleted the includeArbitraryProtocolInWebsocketUpgrade branch December 9, 2018 23:58
marcospereira pushed a commit that referenced this pull request Dec 9, 2018
* Select an arbitrary websocket subprotocol proposed by the client

* Mark method without subprotocol as deprecated

* Add integration test
@marcospereira
Copy link
Member

Backport to 2.7.x: 9d1f9fe

@ppanda2-ford
Copy link

How to use this feature? When we use WebSocket.accept(...) or WebSocket.acceptOrResult(...) with AkkaHttp Server or the Netty Server, it does not pick the subprotocol. What I am missing here, is there any extra configuration needed for this?

@sergiuszkierat
Copy link

@marcospereira is any chance for backport to 2.6.x branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants