Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] jetty client websocket container and cookies

Hi,

You can configure the WebSocketContainer with the Jetty HttpClient which you can set the CookieStore on.
see https://www.eclipse.org/jetty/documentation/jetty-10/programming-guide/index.html#pg-client-http-cookie

You can use the static method `org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainerProvider#getContainer(HttpClient)` to get the container instead the `ContainerProvider.getContainer()` method. This way you can pass in a configured HttpClient.

This could also be done with XML which can help avoid some classloading issues if running in a webapp. Configure the HttpClient in a file named jetty-websocket-httpclient.xml in your resources directory.
example:  https://github.com/eclipse/jetty.project/blob/cd1f146867f66f37df73184a086f0e17828d70c8/tests/test-webapps/test-websocket-client-provided-webapp/src/main/resources/jetty-websocket-httpclient.xml

cheers,
Lachlan

On Sat, Nov 20, 2021 at 4:35 PM Piotr Morgwai Kotarbinski <launchpad@xxxxxxxxxx> wrote:
Hello all,
I have a client app that both issues standard http requests and makes websocket connections (to the same server). Currently I'm using Java-11's built in HttpClient for plain http and Jetty-10's client WebSocketContainer for websockets (obtained with ContainerProvider.getWebSocketContainer()). Now I need these 2 to share cookie storage: for HttpClient I can explicitly set CookieHandler with HttpClient.newBuilder().cookieHandler(cookieManager)....build() but I haven't been able to find any way to configure cookie storage for WebSocketContainer: is it possible to do it somehow?

Thanks!
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top