by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    przemyslaw wierzbicki
    @pshemass
    @quelgar thanks. datagram merged.
    @jczuchnowski @quelgar let me know if you need help with yours PRs. we are close to 1.0 so it would be great to push this through.
    Amitay Horwitz
    @amitayh
    Hi, I added zio-nio with version 0.2.0 - the changelog seem to include DatagramChannel (https://github.com/zio/zio-nio/compare/v0.2.0...master), but i can't seem to find it when using it in the project. What am I missing?
    Lachlan O'Dea
    @quelgar
    hi @amitayh you’re looking at the changes made to master after the 0.2.0 release. So unfortunately DatagramChannel is not in any released jars yet
    Amitay Horwitz
    @amitayh
    oh.. any estimation when they will be released?
    Lachlan O'Dea
    @quelgar
    I don’t know...
    Amitay Horwitz
    @amitayh
    OK, thank you
    Jakub Czuchnowski
    @jczuchnowski
    I think we should be good to go in a couple of days
    przemyslaw wierzbicki
    @pshemass
    @amitayh i will push new version tonight so you will be able to test it.
    Jakub Czuchnowski
    @jczuchnowski
    @pshemass in that case I'll merge zio/zio-nio#68 (fixed the lint error)
    also ZIO/core will release new RC tomorrow I believe
    that will enable merging zio/zio-nio#67
    przemyslaw wierzbicki
    @pshemass
    @jczuchnowski ack
    @mijicd something went wrong with release https://circleci.com/gh/zio/zio-nio/877 please help.
    Dejan Mijić
    @mijicd
    @pshemass I will check it out in ~1 hour
    This is due to the freaking steward
    I forgot to mention everywhere but
    Do not upgrade sbt-pgp
    As version 2.x introduces additional checks
    Which we do not match
    I will downgrade and rerelease
    Dejan Mijić
    @mijicd
    Now
    OK, retagged, build started
    Fingers crossed
    Dejan Mijić
    @mijicd
    @/all artifact is published
    Piotr Gabara
    @pgabara
    Hi Guys, I am trying to create a simple server socket channel like this: https://gist.github.com/pgabara/a4bd2de00365a6a5636e9294bfc06faa. When I start it and try to connect to it I am getting errors like:
    Fiber failed.
    A checked error was not handled.
    java.nio.channels.AsynchronousCloseException
        at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:415)
        at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:191)
        at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.implClose(UnixAsynchronousSocketChannelImpl.java:225)
        at java.base/sun.nio.ch.AsynchronousSocketChannelImpl.close(AsynchronousSocketChannelImpl.java:145)
        at zio.nio.channels.AsynchronousByteChannel.$anonfun$close$1(AsynchronousChannel.scala:56)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at zio.internal.FiberContext.evaluateNow(FiberContext.scala:403)
        at zio.internal.FiberContext.$anonfun$evaluateLater$1(FiberContext.scala:601)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
    
    Fiber:3 was supposed to continue to:
      a future continuation at zio.nio.channels.AsynchronousByteChannel.readBuffer(AsynchronousChannel.scala:26)
      a future continuation at zio.nio.channels.AsynchronousByteChannel.read(AsynchronousChannel.scala:31)
      a future continuation at foxie.Server$.join(Main.scala:31)
      a future continuation at zio.ZIO.as(ZIO.scala:102)
      a future continuation at zio.ZIO.forever(ZIO.scala:454)
    ...
    Can you tell me what I am doing wrong?
    I use 0.2.0 version and Scala 2.13.1
    Jakub Czuchnowski
    @jczuchnowski
    I can take a look in the evening
    svroonland
    @svroonland
    @pgabara I think it's because you fork inside use. Because the stuff inside of use { .. } then completes immediately, the managed resources - the socket connections in this case - are closed immediately. Probably the AsynchronousCloseException comes from the socket.read, which is trying to read from an already closed connection in a forked Fiber.
    Piotr Gabara
    @pgabara
    @jczuchnowski thanks!
    @svroonland thanks! Do you know how to make it to accept many connections concurrently?
    przemyslaw wierzbicki
    @pshemass
    Thanks @mijicd
    Piotr Gabara
    @pgabara
    I fixed the issue: https://gist.github.com/pgabara/a4bd2de00365a6a5636e9294bfc06faa I had to use Reservation[Any, Exception, AsynchronousSocketChannel] instead of Managed[Exception, AsynchronousSocketChannel]. Can I simplify it somehow?
    Itamar Ravid
    @iravid
    @pgabara That doesn't give you any guarantees on resource safety
    e.g. accept could get interrupted between the acquire and before the next flatMap, leading to leaked resources
    If you compose the Managed[AsynchronousServerSocketChannel] and the Managed[AsynchronousSocketChannel] using Managed#flatMap, you can structure your program in a way that will not exit the scope of the resources until your program finishes
    Piotr Gabara
    @pgabara
    @iravid thanks for advice. I will try to rewrite it.
    Denis
    @denisgarci

    Hi, I'm trying to write a simple echo server that can accept multiple connections. I have a working version but it only works with one connection:

    def echoServer(address: SocketAddress): ZIO[Console, Exception, Unit] = {
      for {
        _ <- AsynchronousServerSocketChannel().use { server =>
          for {
            _ <- log(s"Listening on $address")
            _ <- server.bind(address)
            _ <- server.accept.use(socket => socket.read(8).flatMap(chunk => socket.write(chunk)).forever)
          } yield ()
        }
      } yield ()
    }

    How can I accept multiple connections? Should I fork server.accept?

    przemyslaw wierzbicki
    @pshemass
    @jczuchnowski I think we should improve documentation and establish some patterns after changes with Managed because users have hard time to use it.
    @denisgarci yes you should fork and forever accept too.
    Denis
    @denisgarci
    @pshemass thanks before or after the use?
    przemyslaw wierzbicki
    @pshemass
    @denisgarci you got me here :) that's why I mentioned @jczuchnowski we need to improve documentation because I don't know the answer after we changed to use Managed. @pgabara had similar problem please check his solution and @iravid advise.
    Lachlan O'Dea
    @quelgar
    @pshemass I agree this is needed. It’s definitely not obvious how to use Managed in more real-world networking code
    Itamar Ravid
    @iravid
    I’ll be happy to help flesh out those docs during the Berlin hackathon if that is still needed by then :-)
    Denis
    @denisgarci
    @pshemass @iravid thank you!
    Jakub Czuchnowski
    @jczuchnowski
    @pshemass I agree, we need that. Actually I tried to write a simple multithreaded app myself but failed. @iravid I will take you up on this Managed guidance ;)
    Kirill Kushtal
    @kushtal

    Please can someone help me
    I need to write a simple server, than repeatedly listen to the channel and destroy them when this condition is met. Can someone show a simple example of this server?
    I found the client-server example in the ZIO-NIO documentation, but this server accepts only one request (not recursive) and closes the connection.

    https://zio.github.io/zio-nio/docs/usecases/usecases_client_server

    przemyslaw wierzbicki
    @pshemass
    beside this use Reservation which is not safe as @iravid pointed out but it works. we are working on simplifying this. suggestions and PRs are welcome :)