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

OSError: [WinError 10022] An invalid argument was supplied #85

Open
gordonaspin opened this issue Jan 26, 2023 · 4 comments
Open

OSError: [WinError 10022] An invalid argument was supplied #85

gordonaspin opened this issue Jan 26, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@gordonaspin
Copy link

python --version
Python 3.11.1
python .\request_msearch.py
C:\Users\User\Desktop\request_msearch.py:41: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
Exception in callback _ProactorDatagramTransport._loop_reading()
handle: <Handle _ProactorDatagramTransport._loop_reading()>
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 578, in _loop_reading
self._read_fut = self._loop._proactor.recvfrom(self._sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 503, in recvfrom
ov.WSARecvFrom(conn.fileno(), nbytes, flags)
OSError: [WinError 10022] An invalid argument was supplied

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 581, in _loop_reading
self.protocol.error_received(exc)
File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\ssdp_init
.py", line 177, in error_received
raise IOError("Unexpected connection error") from exc
OSError: Unexpected connection error

@gordonaspin
Copy link
Author

I figured out a fix.
add a tuple (hostname/ip_address, None) to the loop.create_datagram_endpoint() call. This binds the socket to the address which is what Windows needs.

@codingjoe
Copy link
Owner

Hi @gordonaspin,

there was an issue in the previous version with Windows. This issue should be fixed in version 1.2. You can use the new CLI to test it.

Cheers!
Joe

@yyjdelete
Copy link

yyjdelete commented Jul 17, 2024

The same for 1.3.0 in win10(22H2, 19045.4651) + Python 3.12.4
And add -b 192.168.xxx.xxx to bind to special ethernet and apply the workaround by gordonaspin works for me.

connect = loop.create_datagram_endpoint(PrintSSDMessageProtocol, family=family, local_addr=(bind, 0))

@codingjoe
Copy link
Owner

@yyjdelete I actually do have a Windows PC now. Do you have a code snipped I could use to reproduce and debug the issue?

@codingjoe codingjoe reopened this Jul 18, 2024
@codingjoe codingjoe added the bug Something isn't working label Jul 18, 2024
@codingjoe codingjoe self-assigned this Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants