Hi Ronny,

I agree that error message is little helpful. Maybe you are sending plain 
Strings to the actor created by Source.actorRef? (Still we might want to 
improve the error message in that case.)

Johannes

On Monday, September 19, 2016 at 12:08:52 AM UTC+2, Ronny Bräunlich wrote:
>
> Hi everyone,
>
> I am quite new to Akka and Websockets. I tried to create a simple 
> Websocket server using Akka HTTP following mostly this example [1].
> Everytime I send a message to my own server I get the following exception:
>
> [ERROR] [09/18/2016 15:37:01.533] 
> [default-akka.actor.default-dispatcher-4] 
> [akka.actor.ActorSystemImpl(default)] WebSocket handler failed with 
> java.lang.String cannot be cast to akka.http.javadsl.model.ws.Message
> java.lang.ClassCastException: java.lang.String cannot be cast to 
> akka.http.javadsl.model.ws.Message
>     at akka.stream.impl.fusing.Map$$anon$8.onPush(Ops.scala:42)
>     at 
> akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:747)
>     at 
> akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:710)
>     at 
> akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:616)
>     at 
> akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:471)
>     at 
> akka.stream.impl.fusing.GraphInterpreterShell.receive(ActorGraphInterpreter.scala:410)
>     at 
> akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:603)
>     at 
> akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:618)
>     at akka.actor.Actor.aroundReceive(Actor.scala:484)
>     at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
>     at akka.actor.ActorCell.invoke(ActorCell.scala:495)
>     at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
>     at akka.dispatch.Mailbox.run(Mailbox.scala:224)
>     at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
>     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
>     at 
> java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
>     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
>     at 
> java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
>
> Currently, I have no idea why it crashes like this because the method 
> handleWebSocketMessages() expects a Flow<Message, Message, T> so there is 
> no chance I could use a String. Did I miss some configuration for implicit 
> conversion?
>
> You can see the server here [2] and the client here [3]. I am using Akka 
> HTTP Core and Experimental 2.12.0-RC1 version 2.4.10.
>
>
> Thank you for your help.
>
> Cheers,
> Ronny
>
> [1] 
> http://markatta.com/codemonkey/blog/2016/04/18/chat-with-akka-http-websockets/
> [2] https://gist.github.com/rbraeunlich/e2582075e2ccc0fd63580bdd95585aa5
> [3] https://gist.github.com/rbraeunlich/eded91382d72a3d90e8182ca1b077d01
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to