Yes, I am sure. This is the only output from the console I get (I even 
tried with println just to be sure :) ):

[DEBUG] [09/16/2017 07:43:11.335] [main] [EventStream(akka://system)] 
logger log1-Logging$DefaultLogger started
[DEBUG] [09/16/2017 07:43:11.336] [main] [EventStream(akka://system)] 
Default Loggers started
[DEBUG] [09/16/2017 07:43:11.411] [main] [AkkaSSLConfig(akka://system)] 
Initializing AkkaSSLConfig extension...
[DEBUG] [09/16/2017 07:43:11.414] [main] [AkkaSSLConfig(akka://system)] 
buildHostnameVerifier: created hostname verifier: 
com.typesafe.sslconfig.ssl.DefaultHostnameVerifier@72c8e7b
[DEBUG] [09/16/2017 07:43:12.270] [system-akka.actor.default-dispatcher-2] 
[akka://system/system/IO-TCP/selectors/$a/0] Successfully bound to 
/0:0:0:0:0:0:0:0:8080
[DEBUG] [09/16/2017 07:43:14.289] [system-akka.actor.default-dispatcher-2] 
[akka://system/system/IO-TCP/selectors/$a/0] New connection accepted
2017-09-16 07:43:14.308 DEBUG [default-dispatcher-3]              
 system.Main$: Connection accepted from /0:0:0:0:0:0:0:1:57557
2017-09-16 07:43:14.434 DEBUG [default-dispatcher-4]              
 system.Main$: Upgrading: 
HttpRequest(HttpMethod(GET),ws://localhost:8080/websocket,List(UpgradeToWebSocket:
 
, Host: localhost:8080, Connection: Upgrade, Pragma: no-cache, 
Cache-Control: no-cache, Upgrade: websocket, Origin: 
chrome-extension://pfdhoblngboilpfeibdedpjgfnlcodoo, Sec-WebSocket-Version: 
13, User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) 
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.83 Safari/537.36 
Vivaldi/1.93.955.14, DNT: 1, Accept-Encoding: gzip, deflate, br, 
Accept-Language: en-GB, en-US;q=0.8, en;q=0.6, Sec-WebSocket-Key: 
3ug15ARDswT6DEfqhw1wdQ==, Sec-WebSocket-Extensions: permessage-deflate; 
client_max_window_bits, Timeout-Access: 
<function1>),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1))

I am using Simple Web Socket Client Chrome extension and it is able to 
connect to the server, it is able to receive the "hello" message from my 
Source but anything I send to the server is not processed and there is even 
no logging from Akka or anything. When I tried the other approach from 
documentation (with combined Sink and Source into Flow) it worked well. 
However I know for sure I will need the separate Sink and Source so that's 
why I need to make this work. Should I share this on GitHub so that you can 
try this out?

<https://lh3.googleusercontent.com/-MmGt4bd6ux4/Wby7LBkY6qI/AAAAAAAAAUU/ZnvS5t7cQAwICPC9hOoLyJ3YDmvsg4meACLcBGAs/s1600/swsc.png>

Thank you. Regards,
Jakub Janecek


On Saturday, September 16, 2017 at 5:56:14 AM UTC+2, Konrad Malawski wrote:
>
> You seem to be logging on debug level there - are you sure your logging 
> configuration is such that it will log/print log statements? 
>
> On September 16, 2017 at 5:18:19, Jakub Janeček (janece...@gmail.com 
> <javascript:>) wrote:
>
>> Hello, 
>>
>> I am trying to implement a simple WebSockets server using akka-http with 
>> separate Sink and Source. According to the documentation I should be using 
>> the handleMessagesWithSinkSource method however if I do so I am not able to 
>> receive any Message. I am able to send some back to the client but nothing 
>> sent to the server is received. Could someone help me out and spot my 
>> mistake? I guess it will be something obvious.
>>
>> import akka.actor.ActorSystem
>> import akka.http.scaladsl.Http
>> import akka.http.scaladsl.Http.IncomingConnection
>> import akka.http.scaladsl.model.HttpMethods.GET
>> import akka.http.scaladsl.model.ws.{Message, TextMessage, 
>> UpgradeToWebSocket}
>> import akka.http.scaladsl.model.{HttpRequest, HttpResponse, Uri}
>> import akka.stream.ActorMaterializer
>> import akka.stream.scaladsl.{Sink, Source}
>> import com.typesafe.config.ConfigFactory
>> import com.typesafe.scalalogging.StrictLogging
>>
>> import scala.concurrent.duration.Duration
>> import scala.concurrent.{Await, ExecutionContextExecutor, Promise}
>>
>> object Main extends StrictLogging {
>>
>>   def main(args: Array[String]): Unit = {
>>     for {
>>       config <- asResource(ConfigFactory.load())
>>       system <- asResource(ActorSystem("system", config), Duration("10s"))
>>       materializer <- asResource(ActorMaterializer()(system))
>>     } {
>>       implicit val s: ActorSystem = system
>>       implicit val m: ActorMaterializer = materializer
>>       implicit val ec: ExecutionContextExecutor = system.dispatcher
>>
>>       val listenAddress = config.getString("listenAddress")
>>       val listenPort = config.getInt("listenPort")
>>       val server = Http().bind(listenAddress, listenPort)
>>
>>       val requestHandler: HttpRequest => HttpResponse = {
>>         case req @ HttpRequest(GET, Uri.Path("/websocket"), _, _, _) =>
>>           req.header[UpgradeToWebSocket] match {
>>             case Some(upgrade) =>
>>               logger.debug(s"Upgrading: $req")
>>               val inHandler = Sink.foreach[Message](x => 
>> logger.debug(s"$x"))
>>               upgrade.handleMessagesWithSinkSource(inHandler, 
>> Source.single(TextMessage("hello")))
>>
>>             case None => HttpResponse(400, entity = "Expected 'Upgrade: 
>> websocket' HTTP header")
>>           }
>>
>>         case req: HttpRequest =>
>>           logger.debug(s"Unexpected: $req")
>>           req.discardEntityBytes() // important to drain incoming HTTP 
>> Entity stream
>>           HttpResponse(404, entity = "URL match not found")
>>       }
>>
>>       val connectionHandler = Sink.foreach { connection: 
>> IncomingConnection =>
>>         logger.debug(s"Connection accepted from 
>> ${connection.remoteAddress}")
>>         connection.handleWithSyncHandler(requestHandler)
>>       }
>>
>>       val binding = server.to(connectionHandler).run()
>>       binding.failed.foreach { ex =>
>>         logger.error(s"Server could not be bound to 
>> $listenAddress:$listenPort", ex)
>>       }
>>
>>       StdIn.readLine()
>>     }
>>   }
>>
>> }
>>
>>
>> Thank you. Regards,
>> Jakub Janecek
>>
>> --
>> >>>>>>>>>> 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+...@googlegroups.com <javascript:>.
>> To post to this group, send email to akka...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
>>>>>>>>>>      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