pymobiledevice3
pymobiledevice3 copied to clipboard
OSError: [WinError 10048] Only one usage of each socket address (protocol/networ k address/port) is normally permitted
Test environment
- Windows 10 Pro
- iPhone XS iOS 16.3
Describe the bug When I try to enable developer mode the phone restarts but I get the socket error, this does not happen on macOS.
Expected behavior Wait for device restart and return successfully
Logs
Traceback (most recent call last):
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 373, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\fastapi\applications.py", line 211, in __call__
await super().__call__(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
raise exc
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "C:\Users\Juan\Documents\Developer\agent\.\api\middleware\check_prerequisites.py", line 41, in __call__
await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\exceptions.py", line 82, in __call__
raise exc
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\routing.py", line 259, in handle
await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\routing.py", line 61, in app
response = await func(request)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\fastapi\routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\fastapi\routing.py", line 161, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\concurrency.py", line 39, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
result = context.run(func, *args)
File "C:\Users\Juan\Documents\Developer\agent\.\api\routers\device.py", line 77, in enable_ios_developer_mode
IOSDeviceManager.enable_developer_mode(device_serial)
File "C:\Users\Juan\Documents\Developer\agent\.\apptim_agent\devices\ios\ios_device_manager.py", line 85, in enable_developer_mode
AmfiService(lockdown).enable_developer_mode()
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\services\amfi.py", line 54, in enable_developer_mode
self._lockdown = LockdownClient(self._lockdown.udid)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\lockdown.py", line 126, in __init__
self.service = ServiceConnection.create(self.medium, self.identifier, self.SERVICE_PORT,
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\service_connection.py", line 104, in create
return ServiceConnection.create_using_usbmux(identifier, port, connection_type=connection_type)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\service_connection.py", line 87, in create_using_usbmux
target_device = select_device(udid, connection_type=connection_type)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 389, in select_device
for device in list_devices():
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 376, in list_devices
mux = create_mux()
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 372, in create_mux
return MuxConnection.create()
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 168, in create
sock = MuxConnection.create_usbmux_socket()
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 148, in create_usbmux_socket
return SafeStreamSocket(MuxConnection.ITUNES_HOST, socket.AF_INET)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 109, in __init__
self.sock.connect(address)
OSError: [WinError 10048] Solo se permite un uso de cada dirección de socket (protocolo/dirección de red/puerto)
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [1888]
Process finished with exit code -1
@morellexf26 thanks for the issue report! :) Can you please verify #429 solves your issue?
@morellexf26 thanks for the issue report! :) Can you please verify #429 solves your issue?
hey! you're welcome. I've tried this,but still have the same problem:
Traceback (most recent call last):
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 373, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\fastapi\applications.py", line 211, in __call__
await super().__call__(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
raise exc
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "C:\Users\Juan\Documents\Developer\agent\.\api\middleware\check_prerequisites.py", line 41, in __call__
await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\exceptions.py", line 82, in __call__
raise exc
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\routing.py", line 259, in handle
await self.app(scope, receive, send)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\routing.py", line 61, in app
response = await func(request)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\fastapi\routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\fastapi\routing.py", line 161, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\starlette\concurrency.py", line 39, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
return await future
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
result = context.run(func, *args)
File "C:\Users\Juan\Documents\Developer\agent\.\api\routers\device.py", line 77, in enable_ios_developer_mode
IOSDeviceManager.enable_developer_mode(device_serial)
File "C:\Users\Juan\Documents\Developer\agent\.\apptim_agent\devices\ios\ios_device_manager.py", line 84, in enable_developer_mode
lockdown = device.get_lockdown()
File "C:\Users\Juan\Documents\Developer\agent\.\apptim_agent\devices\ios\ios_device.py", line 119, in get_lockdown
lockdown_client = LockdownClient(self.id)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\lockdown.py", line 126, in __init__
self.service = ServiceConnection.create(self.medium, self.identifier, self.SERVICE_PORT,
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\service_connection.py", line 104, in create
return ServiceConnection.create_using_usbmux(identifier, port, connection_type=connection_type)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\service_connection.py", line 87, in create_using_usbmux
target_device = select_device(udid, connection_type=connection_type)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 384, in select_device
for device in list_devices():
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 371, in list_devices
mux = create_mux()
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 367, in create_mux
return MuxConnection.create()
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 152, in create
sock = MuxConnection.create_usbmux_socket()
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 143, in create_usbmux_socket
return SafeStreamSocket(MuxConnection.ITUNES_HOST, socket.AF_INET)
File "C:\Users\Juan\AppData\Local\Programs\Python\Python39\lib\site-packages\pymobiledevice3\usbmux.py", line 104, in __init__
self.sock.connect(address)
OSError: [WinError 10048] Solo se permite un uso de cada dirección de socket (protocolo/dirección de red/puerto)
I don't see the amfi.py
in the traceback and unfortunately I don't have a windows PC to test it with. In general, this has something to do with iTunes cannot connect while the device reboots (that's how we detect its startup). If you can, please try to add the thrown exceptions to the list.
i also experienced the same issue, hopefully doronz can return with a fix
Since I cannot reproduce the bug myself, I'd appreciate creating a PR for this. As it looks, its only a matter of wrapping the correct try: .. except ..
arround this error while waiting for the device to reboot
Got a PR with this fix. My current impl is simply not to rely on autoenable, but to send request to enable dev mode and they manyally waiting and trying to connect to accept popup