Search code examples
websocketlagom

How to manually test lagom websocket API?


I downloaded Lagom example project which includes simple websocket endpoint named("example-stream") .withCalls( namedCall("stream", stream) ).withAutoAcl(true) When I launch the app and try to open websocket connection (ws://localhost:9000/stream), the server log prints:

[warn] akka.actor.ActorSystemImpl [sourceThread=application-akka.actor.default-dispatcher-53, akkaSource=akka.actor.ActorSystemImpl(application), sourceActorSystem=application, akkaTimestamp=18:02:21.293UTC] - HTTP header 'Sec-WebSocket-Extens ions: permessage-deflate' is not allowed in requests 20:02:21.301 [warn] runstats-stream [] - Could not negotiate a deserializer for type MessageProtocolImpl(Some(none/none),None,None), the default media type supported is MessageProtocolImpl(Some(text/plain),Some(utf-8),None)

For this, I use Firefox plugin called Browser Websocket client. As far as I know, Websocket handshakes do not require or set Content-Type which apparently lagom websocket endpoint expects.

Am I doing something wrong or is the generated project somehow invalid?


Solution

  • you are not doing anything wrong. Lagom 1.4.0 ships with two different implementations for server-side websocket handling (netty vs AkkaHTTP). The default in implementation in Lagom is the AkkaHTTP-based and we recently discovered an issue. The solution is already worked out but it won't available until we release Lagom 1.4.1.

    In the meantime, you can opt-in to the netty-based implementation (which used to be the default) following the migration guide details on how to select a different server engine.