Using Lagom 1.4.2, I’ve got a strange behavior with a WebSocket connection: the Set-Cookie
is missing (everything is ok for GET requests).
My WebSocket code in the web gateway (play) is very trivial
def ws: WebSocket = WebSocket.acceptOrResult[String, String] {
r: RequestHeader =>
{
println(s"Request Headers : ${r.headers}")
r match { /* process request */ }
}
}
I test this WebSocket using wscat
where I add extra headers:
wscat -H "Set-Cookie:COOKIE=VALUE" -H "X-Auth-Token: token" -H "MyHeader: dummy" -c ws://localhost:9000/ws
What I expect is to simply get all my headers (cookie and custom headers) in the request header of my WebSocket.
Unfortunately, if I use the following main Loader with Lagom components
abstract class WebGateway(context: Context) extends BuiltInComponentsFromContext(context)
/* other traits : implementation details */
with LagomConfigComponent
with LagomServiceClientComponents { /* ... */ }
class WebGatewayLoader extends ApplicationLoader with utils.Logger {
override def load(context: Context): Application = {
(new WebGateway(context) with LagomDevModeComponents).application
}
}
Header Set-Cookie
is missing but the 2 others are there:
Request Headers : List((Remote-Address,127.0.0.1:65182), (UpgradeToWebSocket,), (Raw-Request-URI,/ws), (Tls-Session-Info,[Session-1, SSL_NULL_WITH_NULL_NULL]), (Upgrade,websocket), (Connection,upgrade), (Sec-WebSocket-Key,+4sAzV9rzXRlPDDqmsS05g==), (Sec-WebSocket-Version,13), (X-Auth-Token,token), (MyHeader,dummy), (Origin,ws://localhost:9000), (Host,localhost:9000), (User-Agent,akka-http/10.0.11), (Timeout-Access,<function1>))
If I use the following main Loader without Lagom components
class WebGateway(context: Context) extends BuiltInComponentsFromContext(context)
/* other traits : implementation details */
{ /* ... */ }
class WebGatewayLoader extends ApplicationLoader with utils.Logger {
override def load(context: Context): Application = {
(new WebGateway(context)).application
}
}
Header “Set-Cookie” is there with the 2 others:
List((Remote-Address,127.0.0.1:65472), (UpgradeToWebSocket,), (Raw-Request-URI,/ws), (Tls-Session-Info,[Session-1, SSL_NULL_WITH_NULL_NULL]), (Sec-WebSocket-Version,13), (Sec-WebSocket-Key,Rg3CBczx0wKPWRB+8S8GIg==), (Connection,Upgrade), (Upgrade,websocket), (Set-Cookie,COOKIE=VALUE), (X-Auth-Token,token), (MyHeader,dummy), (Sec-WebSocket-Extensions,permessage-deflate; client_max_window_bits), (Origin,ws://localhost:9000), (Host,localhost:9000), (Timeout-Access,<function1>))
Obviously, to be able to do so, all services have been removed.
Do you have an explanation or a workaround?