-
Notifications
You must be signed in to change notification settings - Fork 404
Open
Description
Describe the bug
when i start opc ua server and try to stop them, then exception 'Exception raised while processing message from client' generated.
To Reproduce
Minimal code:
import asyncio
from asyncua import Server, __version__
from asyncua.common.methods import uamethod
import keyboard
async def main():
server = Server()
await server.init()
server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
print(__version__)
async with server:
while True:
if keyboard.is_pressed('q'):
break
await asyncio.sleep(0.1)
if __name__ == "__main__":
asyncio.run(main(), debug=True)
after start, when 'q' pressed, then exception generated
Version
Python-Version: 3.13.0, 3.13.5 (32bit)
opcua-asyncio Version: 1.1.6
Sollution for me
File asyncua\server\binary_server_asyncio.py
class BinaryServer
method stop
. Change to:
async def stop(self):
self.logger.info("Closing asyncio socket server")
for transport in self.iserver.asyncio_transports:
transport.close()
# move to here
if self._server:
asyncio.get_running_loop().call_soon(self._server.close)
await self._server.wait_closed()
# stop cleanup process and run it a last time
if self.cleanup_task is not None:
self.cleanup_task.cancel()
try:
await self.cleanup_task
except asyncio.CancelledError:
pass
await self._close_tasks()
# move from here
# if self._server:
# asyncio.get_running_loop().call_soon(self._server.close)
# await self._server.wait_closed()
Metadata
Metadata
Assignees
Labels
No labels