darkdragonsastro / python-alpaca-server

Apache License 2.0
1 stars 1 forks source link

reuse_socket=true not working under windows #1

Open grbsystems opened 3 days ago

grbsystems commented 3 days ago

Using python 3.12.7 under windows 11 the discovery server appears to start, but never publishes a port.

There is an issue with the following code in the start method:

self.socket = await asyncudp.create_socket( local_addr=("0.0.0.0", 32227), reuse_port=True )

reuse_port=True doesn't raise any errors, but the port is never created. Netstat doesn't show it, and alpaca discovery fails.

Changing to self.socket = await asyncudp.create_socket(local_addr=("0.0.0.0", 32227)) succeeds.

The cause is that Windows does not support SO_REUSEPORT. See https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.create_datagram_endpoint, which is the underlying API call made by asyncudp.

An alternative might have been to use SO_REUSEADDR, but asyncudp does not expose this option as a passthrough.

rickbassham commented 3 days ago

Thanks Jeremy, I'll take a look.