AzurLaneAutoScript icon indicating copy to clipboard operation
AzurLaneAutoScript copied to clipboard

Incorrectly selects emulator port (address) when the port is changed, but detects the emulator itself

Open Oplik2 opened this issue 1 year ago • 1 comments

在提问之前...

  • [X] 我已经搜索了现有的 issues
  • [X] 我在提问题之前至少花费了 5 分钟来思考和准备
  • [X] 我已经阅读了 Wiki 中的 常见问题(FAQ)
  • [X] 我正在使用最新版的 Alas

描述你的问题

If the local address in emu changed (first use at 5556. after reboot at 5555, third time 5559) the app correctly detects the new address but fails to connect, as even though it has the new detected address, it tries the old one instead of updating. If it detects new address it should auto update instead of requiring manual checkup.

Would be nice to fix as it hinders usage when hosting on machines like mine where dynamic port allocation is used and not managed by default OS, as sometimes the emulator does not have a port available and picks the next one by default (case of recent bluestack i believe)

Only case where new address should not be used is when running multiple instances where manual setting is better

如何复现

  1. 前往 '...'
  2. 点击 '....'
  3. 滑动到 '....'
  4. 出现问题

Use bluestack default adb address

Reboot

Use software to assign local address and port to bluestack

Use bluestack with new adb adress

App detect new address but does not switch to it (uses one set manually or by predecesing auto-select)

预期行为

If new address and port is detected, app should change automatically

相关 Logs

INFO     21:54:08.036 │ DEVICE                                                                    
INFO     21:54:08.037 │ [IS_ON_PHONE_CLOUD] False                                                 
INFO     21:54:08.037 │ [AdbBinary] C:\Users\Oplik\Desktop\f\AlasApp_0.4.6_full                   
         (1)\AzurLaneAutoScript\toolkit\Lib\site-packages\adbutils\binaries\adb.exe               
INFO     21:54:08.040 │ [AdbClient] AdbClient(127.0.0.1, 5037)                                    
INFO     21:54:08.040 │ <<< DETECT DEVICE >>>                                                     
INFO     21:54:08.040 │ Here are the available devices, copy to Alas.Emulator.Serial to use it or 
         set Alas.Emulator.Serial="auto"                                                          
INFO     21:54:08.042 │ emulator-5554                                                             
INFO     21:54:10.047 │ cannot connect to 127.0.0.1:5556: No connection could be made because the 
         target machine actively refused it. (10061)                                              
INFO     21:54:10.048 │ cannot connect to 127.0.0.1:5556: No connection could be made because the 
         target machine actively refused it. (10061)                                              
WARNING  21:54:10.049 │ No such device exists, please restart the emulator or set a correct serial
───────────────────────────────────── FIND EMULATOR INSTANCE ─────────────────────────────────────
INFO     21:54:10.052 │ FIND EMULATOR INSTANCE                                                    
INFO     21:54:10.077 │ BlueStacks5(serial="127.0.0.1:5555", name="Pie64", path="C:/Program       
         Files/BlueStacks_nxt/HD-Player.exe")                                                     
WARNING  21:54:10.079 │ No emulator instance with {'serial': '127.0.0.1:5556'}, serial invalid    
CRITICAL 21:54:10.079 │ No emulator with serial "127.0.0.1:5556" found, please set a correct      
         serial                                                                                   
ERROR    21:54:10.081 │ EmulatorNotRunningError:                                                  
         ╭────────────────────────── Traceback (most recent call last) ──────────────────────────╮
         │                                                                                       │
         │ C:\Users\Oplik\Desktop\f\AlasApp_0.4.6_full (1)\AzurLaneAutoScript\alas.py:46 in      │
         │ device                                                                                │
         │                                                                                       │
         │    44 │   │   try:                                                                    │
         │    45 │   │   │   from module.device.device import Device                             │
         │ ❱  46 │   │   │   device = Device(config=self.config)                                 │
         │    47 │   │   │   return device                                                       │
         │    48 │   │   except RequestHumanTakeover:                                            │
         │                                                                                       │
         │ ╭──────────────────────────── locals ─────────────────────────────╮                   │
         │ │ Device = <class 'module.device.device.Device'>                  │                   │
         │ │      e = EmulatorNotRunningError()                              │                   │
         │ │   self = <alas.AzurLaneAutoScript object at 0x000001D94E9FE748> │                   │
         │ ╰─────────────────────────────────────────────────────────────────╯                   │
         │ C:\Users\Oplik\Desktop\f\AlasApp_0.4.6_full                                           │
         │ (1)\AzurLaneAutoScript\module\device\device.py:72 in __init__                         │
         │                                                                                       │
         │    70 │   │   for _ in range(2):                                                      │
         │    71 │   │   │   try:                                                                │
         │ ❱  72 │   │   │   │   super().__init__(*args, **kwargs)                               │
         │    73 │   │   │   │   break                                                           │
         │    74 │   │   │   except EmulatorNotRunningError:                                     │
         │                                                                                       │
         │ ╭───────────────────────────────────── locals ──────────────────────────────────────╮ │
         │ │ __class__ = <class 'module.device.device.Device'>                                 │ │
         │ │         _ = 0                                                                     │ │
         │ │      args = ()                                                                    │ │
         │ │    kwargs = {                                                                     │ │
         │ │             │   'config': <module.config.config.AzurLaneConfig object at          │ │
         │ │             0x000001D94EA013C8>                                                   │ │
         │ │             }                                                                     │ │
         │ │      self = <module.device.device.Device object at 0x000001D94F4FDA08>            │ │
         │ ╰───────────────────────────────────────────────────────────────────────────────────╯ │
         │                                                                                       │
         │ C:\Users\Oplik\Desktop\f\AlasApp_0.4.6_full                                           │
         │ (1)\AzurLaneAutoScript\module\device\connection.py:112 in __init__                    │
         │                                                                                       │
         │    110 │   │                                                                          │
         │    111 │   │   # Connect                                                              │
         │ ❱  112 │   │   self.adb_connect(self.serial)                                          │
         │    113 │   │   logger.attr('AdbDevice', self.adb)                                     │
         │    114                                                                                │
         │                                                                                       │
         │ ╭──────────────────────────────────── locals ────────────────────────────────────╮    │
         │ │ __class__ = <class 'module.device.connection.Connection'>                      │    │
         │ │    config = <module.config.config.AzurLaneConfig object at 0x000001D94EA013C8> │    │
         │ │      self = <module.device.device.Device object at 0x000001D94F4FDA08>         │    │
         │ ╰────────────────────────────────────────────────────────────────────────────────╯    │
         │                                                                                       │
         │ C:\Users\Oplik\Desktop\f\AlasApp_0.4.6_full                                           │
         │ (1)\AzurLaneAutoScript\module\base\decorator.py:70 in wrapper                         │
         │                                                                                       │
         │    68 │   │   │   │   │   │   continue                                                │
         │    69 │   │   │   │   │                                                               │
         │ ❱  70 │   │   │   │   │   return record['func'](self, *args, **kwargs)                │
         │    71 │   │   │   │                                                                   │
         │    72 │   │   │   │   logger.warning(f'No option fits for {name}, using the last defi │
         │       func.')                                                                         │
         │                                                                                       │
         │ ╭─────────────────────────────────── locals ───────────────────────────────────╮      │
         │ │   args = ('127.0.0.1:5556',)                                                 │      │
         │ │    cls = <class 'module.base.decorator.Config'>                              │      │
         │ │   flag = [True]                                                              │      │
         │ │   func = <function Connection.adb_connect at 0x000001D90D9B95E8>             │      │
         │ │ kwargs = {}                                                                  │      │
         │ │ logger = <Logger alas (INFO)>                                                │      │
         │ │   name = 'adb_connect'                                                       │      │
         │ │ record = {                                                                   │      │
         │ │          │   'options': {'DEVICE_OVER_HTTP': False},                         │      │
         │ │          │   'func': <function Connection.adb_connect at 0x000001D90D9B94C8> │      │
         │ │          }                                                                   │      │
         │ │   self = <module.device.device.Device object at 0x000001D94F4FDA08>          │      │
         │ ╰──────────────────────────────────────────────────────────────────────────────╯      │
         │                                                                                       │
         │ C:\Users\Oplik\Desktop\f\AlasApp_0.4.6_full                                           │
         │ (1)\AzurLaneAutoScript\module\device\connection.py:625 in adb_connect                 │
         │                                                                                       │
         │    623 │   │   │   │   logger.info(msg)                                               │
         │    624 │   │   │   │   logger.warning('No such device exists, please restart the emul │
         │        set a correct serial')                                                         │
         │ ❱  625 │   │   │   │   raise EmulatorNotRunningError                                  │
         │    626 │   │                                                                          │
         │    627 │   │   # Failed to connect                                                    │
         │                                                                                       │
         │ ╭───────────────────────────────────── locals ──────────────────────────────────────╮ │
         │ │      _ = 0                                                                        │ │
         │ │ device = AdbDevice(emulator-5554, device)                                         │ │
         │ │    msg = 'cannot connect to 127.0.0.1:5556: No connection could be made because   │ │
         │ │          the target'+37                                                           │ │
         │ │   self = <module.device.device.Device object at 0x000001D94F4FDA08>               │ │
         │ │ serial = '127.0.0.1:5556'                                                         │ │
         │ ╰───────────────────────────────────────────────────────────────────────────────────╯ │
         ╰───────────────────────────────────────────────────────────────────────────────────────╯
         EmulatorNotRunningError

截图

No response

还有别的吗?

No response

Oplik2 avatar Jun 17 '24 13:06 Oplik2

In some extreme cases, the emulator instance will unhook connections with the multiplayer program, thus it can only be found in task manager ;_;. If u launch a new emulator instance, the program will detect that ur port (127.0.0.1:5555) is already occupied, then it's going to add some value to 5555, which depends on different emulator environment. Alas is too hard to match many kinds of emulator environ, at present there is no good solution to solve it. U can restart emulator at least twice, or set serial to auto. :)

PPPlatelet avatar Jun 20 '24 17:06 PPPlatelet