Closed elyphas closed 1 year ago
I found more info:
ws_taak 19:17:20.838 [default-akka.actor.default-dispatcher-11] INFO akka.actor.DeadLetterActorRef - Message [mycelium.core.message.CallResponse] from Actor[akka://default/user/$a#-430912052] to Actor[akka://default/deadLetters] was not delivered. [2] dead letters encountered. If this is not an expected behavior then Actor[akka://default/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
ws_taak 19:17:20.840 [default-akka.actor.default-dispatcher-11] INFO akka.actor.DeadLetterActorRef - Message [mycelium.core.message.CallResponse] from Actor[akka://default/user/$a#-430912052] to Actor[akka://default/deadLetters] was not delivered. [3] dead letters encountered. If this is not an expected behavior then Actor[akka://default/deadLetters] may have terminated unexpectedly. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'
Problem solved I changed this:
//val handler = new FullRequestHandler[ByteBuffer, String, String, Option[String]] {
val handler = new SimpleRequestHandler[ByteBuffer, String, String, Option[String]] {
and I got some functions out
well, sorry, no what I was hoping And the problem seems is in this function:
val handler = new FullRequestHandler[ByteBuffer, String, String, Option[String]] {
override def onClientConnect(
client: NotifiableClient[String, Option[String]],
state: Future[Option[String]]): Unit = {
//This is generating my problem and I don´t know how to solve it
//client.notify ( _ => Future.successful ( "started" :: Nil ) )
clients += client
()
}
....
I am not sure. The class-cast exception looks suspicious to me.From the stack trace, it seems to fail serializing an outgoing message.
So, when you notify with your string-events, you are sending them downstream and serialize them. They are using boopickle and there seems to cast a List
as a String
. Just a guess in the wild, but could there be a cast inside on of your own picklers?
"could there be a cast inside on of your own picklers?"
no, this is my code.
object FullRequestHandler {
implicit val executionContext = scala.concurrent.ExecutionContext.Implicits.global
type Payload = ByteBuffer
val handler = new FullRequestHandler[ByteBuffer, String, String, Option[String]] {
//val handler = new SimpleRequestHandler[ByteBuffer, String, String, Option[String]] {
val clients = mutable.HashSet.empty[NotifiableClient[String, Option[String]]]
val events = mutable.ArrayBuffer.empty[String]
override val initialState = Future.successful(None)
override def onRequest(client: NotifiableClient[String, Option[String]], state: Future[Option[String]], path: List[String], payload: ByteBuffer) = {
def deserialize[S: Pickler](ts: ByteBuffer) = Unpickle[S].fromBytes(ts)
def serialize[S: Pickler](ts: S) = Right(Pickle.intoBytes[S](ts))
def value[S: Pickler](ts: S, events: List[String] = Nil) = Future.successful(ReturnValue(serialize(ts), events))
def valueFut[S: Pickler](ts: Future[S], events: List[String] = Nil) = ts.map(ts => ReturnValue(serialize(ts), events))
def error(ts: String, events: List[String] = Nil) = Future.successful(ReturnValue(Left(ts), events))
path match {
case "getAllTypeDocuments" :: Nil => Response(state, value(true))
case "getAllUsers" :: Nil => Response(state, value(true))
}
}
override def onEvent(client: NotifiableClient[String, Option[String]], state: Future[Option[String]], newEvents: List[String]) = {
events ++= newEvents
val downstreamEvents = newEvents.map(event => s"${event}-ok")
downstreamEvents.foreach(println)
Reaction(state, Future.successful(downstreamEvents))
}
override def onClientConnect(client: NotifiableClient[String, Option[String]], state: Future[Option[String]]): Unit = {
client.notify ( _ => Future.successful ( "started" :: Nil ) )
clients += client
()
}
override def onClientDisconnect( client: NotifiableClient[String, Option[String]], state: Future[Option[String]], reason: DisconnectReason): Unit = {
clients -= client
()
}
}
}
object RESTServer extends App {
import FullRequestHandler._
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
implicit val executionContext = scala.concurrent.ExecutionContext.Implicits.global
import myceliumHandler.FullRequestHandler._
val builder = implicitly[AkkaMessageBuilder[ByteBuffer]]
val serializer = implicitly[Serializer[ClientMessage[ByteBuffer], ByteBuffer]]
val deserializer = implicitly[Deserializer[ServerMessage[ByteBuffer, String, String], ByteBuffer]]
val config = WebsocketServerConfig(bufferSize = 5, overflowStrategy = OverflowStrategy.fail)
val server = WebsocketServer.withPayload(config, handler)
val binding = Http().newServerAt(interface, port).bindFlow(handleWebSocketMessages(server.flow()))
}
Well, seems is a conflict between libraries but it compiles without errors. I get back to "0.1.0" it works very fine, but when I upgrade to "0.2.0" happens the error. Thank you.
I am having a problem while mycelium is trying to set a connection. The error is this: Any idea? please the mycelium version is 0.3.1