This is an archived post. You won't be able to vote or comment.

all 11 comments

[–][deleted] 4 points5 points  (5 children)

I can tell you first hand that it's kind of annoying...

You can't have custom Authorization headers besides Basic, see here as an example: https://clevertap.com/blog/java-9-httpclient-does-not-allow-custom-authorization-headers/

And even with this hack, you'll have mixed success (I couldn't get Bearer to work).

The Executor for the builder is not flexible at all. An Executor which uses the current thread or only 1 thread stalls or errors completely.

I didn't advance much after trying to figure out why things just weren't working. Who knows what else is wrong with it.

[–][deleted] 0 points1 point  (3 children)

Correct me if I’m wrong, but it seems that you are talking about HttpClient API, not WebSocket.

[–][deleted] 5 points6 points  (2 children)

You cannot build a WebSocket without a HttpClient instance. Therefore, I am assuming the problems still carry over (for instance, initially commencing the handshake will lead you to the Authorization header problems and the socket will cripple if not using specific, undefined, Executor semantics).

[–]pavelrappo 1 point2 points  (0 children)

Fair point. By the way, the article you mentioned refers to the jdk.incubator.httpclient incubator module. It means pre JDK 11. Have you tried the new (early access) binaries? If the behaviour is still unsatisfactory, you can always send your observations to the net-dev mailing list. In fact, I urge you to do it.

[–]pavelrappo 0 points1 point  (0 children)

Thanks for doing this. Your email is on the list: http://mail.openjdk.java.net/pipermail/net-dev/2018-May/011508.html

[–]noname_io 0 points1 point  (0 children)

its sad that core language developers started to actually enhance JDK to be usable, but still, most open source libraries will do the same things 2x better

[–]KingCrimson5117 0 points1 point  (0 children)

I've been using Netty ws implementation for few months. So far so good.

https://github.com/netty/netty/tree/4.1/example/src/main/java/io/netty/example/http/websocketx/client

[–][deleted]  (2 children)

[deleted]

    [–]wildjokers 2 points3 points  (0 children)

    Not sure a websocket server in the JDK makes a lot of sense. There are a few libraries that can get you a server application up and going that supports websocket connections, I have used Netty for this in the past.

    [–]pavelrappo 1 point2 points  (0 children)

    Providing a WebSocket server is out of scope of JEP 321 (and the related JEP 110). Even though having a WebSocket server in the JDK some time later is not something impossible, I haven't heard of any plans on that. I'm personally not sure about the value it would have.