Skip to content

udp sendto not working #319

Closed
Closed

Description

@stalkerg
  • uvloop version: 0.14.0
  • Python version: 3.7.6
  • Platform: Linux
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in env?: yes
  • Does uvloop behave differently from vanilla asyncio? How?: not working

Hello. Currently, I am trying to work with aiosip project and it's working very well but unfortunately, it stops working after installing uvloop.
It looks like sendto do nothing and without any error. I can't see any UDP packet on any device.

Probably I should go deeply with gdb.

PS datagram endpoint created fine and without exceptions https://github.com/stalkerg/aiosip/blob/master/aiosip/peers.py#L316

Activity

  1. stalkerg commented on Mar 2, 2020

    @stalkerg
    Author

    with uvloop 0.13.0 I have next error:

      File "uvloop/loop.pyx", line 2980, in create_datagram_endpoint
      File "uvloop/handles/udp.pyx", line 86, in uvloop.loop.UDPTransport._connect
    OSError: [Errno 106] Transport endpoint is already connected
    

    in same time with classic eventloop I have no any problems.

  2. stalkerg commented on Mar 2, 2020

    @stalkerg
    Author

    ok, with version 0.12.2 everything working fine.

  3. stalkerg commented on Mar 2, 2020

    @stalkerg
    Author

    after bisect I found this commit c2b65bc it's break UDP for aiosip (and I think not only).

  4. 1st1 commented on Mar 4, 2020

    @1st1
    Member

    Thanks for reporting this. Could you please write a functional test that would exhibit the bug?

  5. stalkerg commented on Mar 5, 2020

    @stalkerg
    Author

    @1st1 yes, please

    import asyncio
    import uvloop
    
    uvloop.install()
    
    
    class UDP(asyncio.DatagramProtocol):
        def __init__(self):
            pass
    
        def connection_lost(self, error):
            print("connection_lost", error)
    
    
    async def main():
        loop = asyncio.get_event_loop()
        transport, proto = await loop.create_datagram_endpoint(
            lambda: UDP(),
            local_addr=("192.168.1.9", 6001),
            remote_addr=("192.168.1.3", 5060)
        )
        print("Before sending the message without a destination")
        transport.sendto(b"deadbeef")
        await asyncio.sleep(1)
        print("After sending the message without a destination")
        
        print("Before sending the message with a destination")
        transport.sendto(b"deadbeef", ("192.168.1.3", 5060)) # will be connection lost
        await asyncio.sleep(1)
        print("After sending the message with a destination")
    
    
    asyncio.get_event_loop().run_until_complete(main())

    looks like it happens if you trying to send a message with destination address and you have already specified it in create_datagram_endpoint as remote_addr. Without uvloop all working perfectly.

  6. jlaine commented on Mar 5, 2020

    @jlaine
    Contributor

    You cannot both "connect" the endpoint to a remote address and use sendto() with a destination address.

    This is the case in vanilla asyncio too:

    https://github.com/python/cpython/blob/85cf1d514b84dc9a4bcb40e20a12e1d82ff19f20/Lib/asyncio/selector_events.py#L1028

    I wonder if uvloop is raising ValueError as it should?

    EDIT My bad if the same remote address is used for create_datagram_endpoint and sendto it works with vanilla asyncio, so it should work with uvloop too.

  7. added 2 commits that reference this issue on Apr 10, 2020
    7a73c97
    c952030
  8. added a commit that references this issue on Apr 11, 2020
    1d9267a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions