Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.7.1 64bit, Win7 64bit problem to read and write with UDP. #55840

Closed
KristofferNilsson mannequin opened this issue Mar 22, 2011 · 11 comments
Closed

Python 2.7.1 64bit, Win7 64bit problem to read and write with UDP. #55840

KristofferNilsson mannequin opened this issue Mar 22, 2011 · 11 comments

Comments

@KristofferNilsson
Copy link
Mannequin

KristofferNilsson mannequin commented Mar 22, 2011

BPO 11631
Nosy @loewis, @pitrou, @tiran
Files
  • recvfrom_fail.py: Script which should reproduce the recvfrom bug
  • server.py
  • client.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-11-06.22:03:19.189>
    created_at = <Date 2011-03-22.09:30:38.896>
    labels = ['expert-IDLE', 'invalid', 'OS-windows']
    title = 'Python 2.7.1 64bit, Win7 64bit problem to read and write with UDP.'
    updated_at = <Date 2012-11-06.22:03:18.905>
    user = 'https://bugs.python.org/KristofferNilsson'

    bugs.python.org fields:

    activity = <Date 2012-11-06.22:03:18.905>
    actor = 'christian.heimes'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-11-06.22:03:19.189>
    closer = 'christian.heimes'
    components = ['IDLE', 'Windows']
    creation = <Date 2011-03-22.09:30:38.896>
    creator = 'Kristoffer.Nilsson'
    dependencies = []
    files = ['26905', '26914', '26915']
    hgrepos = []
    issue_num = 11631
    keywords = []
    message_count = 11.0
    messages = ['131731', '131760', '131762', '131767', '131774', '168603', '168605', '168606', '168627', '175008', '175014']
    nosy_count = 6.0
    nosy_names = ['loewis', 'pitrou', 'christian.heimes', 'santoso.wijaya', 'Kristoffer.Nilsson', 'sadmoody']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue11631'
    versions = ['Python 2.7']

    @KristofferNilsson
    Copy link
    Mannequin Author

    KristofferNilsson mannequin commented Mar 22, 2011

    Running Windows 7 Enterprise 64 bit, and Python 7.2.1 64 bit Python failed to read and send UDP packages when ran in cmd.exe. This is not the case when ran with IDLE.

    Example; two simple programs. First one listening to a UDP port

    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(('', 10015))

    reading data from socket and printing the received data, using;
    data, addr = sock.recvfrom(1024)

    this will lock, if not ran from IDLE.

    Same for sending data, using;

    sock.sendto(DATA_MESSAGE, (HOST, 10015))

    this will work with both, but only send when running from IDLE.

    @santosowijaya
    Copy link
    Mannequin

    santosowijaya mannequin commented Mar 22, 2011

    this will lock

    I should expect so! recvfrom is a blocking method. The interpreter will block on said socket until (if recvfrom) data arrives from the remote end of the socket.

    sendto is non-blocking, though. And it works for me:

    Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import socket
    >>> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    >>> sock.sendto('data', ('localhost', 1005))
    4
    >>>

    @KristofferNilsson
    Copy link
    Mannequin Author

    KristofferNilsson mannequin commented Mar 22, 2011

    Ah, bad formulation by me. While testing I had both the same machine and external machine sending UDP packages to the port I was listening to.

    The listening server would not receive anything on 64/64bit (unless running from IDLE).

    The reverse try, running the listening server (same program) on another computer, it would receive only from its own stream (while the 64/64 would only send packages while running from IDLE).

    This was verified running Wireshark on both machines.

    So in short, the 64/64 running from cmd.exe would not send or receive on UDP, while running from IDLE this was not the case.

    @santosowijaya
    Copy link
    Mannequin

    santosowijaya mannequin commented Mar 22, 2011

    I can't reproduce this. I'm also running 64-bit Python on 64-bit Windows 7 and socket operations are fine for me.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Mar 22, 2011

    Kristoffer: are you using a personal firewall software? These filters often filter traffic out depending on what process is receiving it, so you may want to turn the firewall off (or explicitly configure it to allow this port to be open).

    @sadmoody
    Copy link
    Mannequin

    sadmoody mannequin commented Aug 19, 2012

    I am facing this same issue.

    I set recvfrom to have a timeout of 5 seconds and stuck it in an infinite loop with some response code based on what is received.

    The sending functionality of the socket is not compromised at all. It can always send. However, after about 10-20 minutes of normal operation (i.e. packets are being sent and received properly) - python stops being able to receive packets (but is still able to send them).

    Cross-checking this with wireshark showed me that incoming packets are being received by the system (so the problem is somewhere between receiving them on the network adapter and accessing it in python).

    I'm running 64bit Windows 7 with 2 network adapters (wired and wireless).

    I also tried running the same python script in 4-200 processes simultaneously (but on different ports), and the error happens at the same time for ALL windows.

    All firewalls are disabled.

    @pitrou
    Copy link
    Member

    pitrou commented Aug 19, 2012

    I set recvfrom to have a timeout of 5 seconds and stuck it in an
    infinite loop with some response code based on what is received.

    Does it make a difference if you set specify a timeout?
    Could you upload a script that reproduces the issue?
    Also, which Python version have you been running?

    @sadmoody
    Copy link
    Mannequin

    sadmoody mannequin commented Aug 19, 2012

    I'm unsure what you mean by "set specify" a timeout, but I do use the "settimeout()" function.

    I've stripped my program of everything that is not dealing with the socket and replaced the string being sent back with a dummy one. But this is essentially how it's laid out.

    I'm using Python 2.7.2

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Aug 20, 2012

    I still can't reproduce it. I'm attaching client and server scripts that communicate over 127.0.0.1. This works just fine.

    @sadmoody
    Copy link
    Mannequin

    sadmoody mannequin commented Nov 6, 2012

    I solved the problem - sorry it's taken me so long to reply. I know how frustrating it is when people don't respond with what they found out in the end.

    Turns out there's no bug as you said and it was based around something I did (as these things usually are). I was passing the packet as a string through redis before sending it which caused it to modify some bytes in there after they passed a certain value. I pickled the messages and it all worked in the end.

    Sorry about the trouble and thanks for the help!

    @tiran
    Copy link
    Member

    tiran commented Nov 6, 2012

    Thanks for your response! I'm closing the ticket.

    @tiran tiran closed this as completed Nov 6, 2012
    @tiran tiran added the invalid label Nov 6, 2012
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants