pythonmitmproxy

mitm proxy is closed, but the port is still occupied


I started a dumpMaster service, and I tried to shut down the service and release the port it occupies in the python code, but I failed. Detailed code:https://github.com/lingting/debug/blob/python/mitm.py

I want to close the mitm service through python code and release the occupied port. But the results of my current attempts are to close the mitm service, but the port is not released

OS: Windows 11 22H2

mitm: 9.0.1

enter image description here


Solution

  • # start
    fun _start():
      await self.master.run()
      await self.master.running()
    self._task = self._loop.create_task(self._start())
    self._loop.run_until_complete(self._task)
    
    # stop
    self.master.shutdown()
    self._task.done()