zoukankan      html  css  js  c++  java
  • macOS系统执行Java项目时报错:Fatal Error: listen EADDRINUSE: address already in use 127.0.0.1:22346

    macOS系统中执行Java项目(UI自动化工程)时报错:

    [HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
    Fatal Error: listen EADDRINUSE: address already in use 127.0.0.1:22346
    ——(22346端口 被占用)
       

     报错信息如下:

    [HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
    Fatal Error: listen EADDRINUSE: address already in use 127.0.0.1:22346
        at Server.setupListenHandle [as _listen2] (net.js:1318:16)
        at listenInCluster (net.js:1366:12)
        at doListen (net.js:1503:7)
        at processTicksAndRejections (internal/process/task_queues.js:81:21)
    org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command '/Library/android-sdk-macosx/platform-tools/adb -P 5037 -s 66J0218C21003454 install -g /usr/local/lib/node_modules/appium/node_modules/_io.appium.settings@3.2.1@io.appium.settings/apks/settings_apk-debug.apk' timed out after 60000ms'. Try to increase the 60000ms adb execution timeout represented by 'androidInstallTimeout' capability
    Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
    System info: host: 'XXX.local', ip: 'fe80:0:0:0:10f4:6862:d396:fc00%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_201'
    Driver info: driver.version: AndroidDriver
    remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command '/Library/android-sdk-macosx/platform-tools/adb -P 5037 -s 66J0218C21003454 install -g /usr/local/lib/node_modules/appium/node_modules/_io.appium.settings@3.2.1@io.appium.settings/apks/settings_apk-debug.apk' timed out after 60000ms'. Try to increase the 60000ms adb execution timeout represented by 'androidInstallTimeout' capability
        at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@7.4.1@appium-base-driver/lib/protocol/errors.js:804:9)
        at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/_appium-base-driver@7.4.1@appium-base-driver/lib/protocol/protocol.js:380:37)
    Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
    System info: host: 'XXXXX.local', ip: 'fe80:0:0:0:10f4:6862:d396:fc00%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.16', java.version: '1.8.0_201'
    Driver info: driver.version: AndroidDriver
        at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
        at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
        at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
        at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
        at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
        at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
        at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:336)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
        at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:37)
        at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:88)
        at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:98)
        at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:94)
        at com. .tool.ui.appium.manager.AppiumDriverManager.initAndroidDriver(AppiumDriverManager.java:174)
        at com. .tool.ui.appium.manager.AppiumDriverManager.initDriver(AppiumDriverManager.java:66)
        at com. .tool.ui.BaseTestCase.initAppiumDriver(BaseTestCase.java:85)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
        at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
        at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:458)
        at org.testng.internal.Invoker.invokeConfigurations(In

    【解决办法】

      由于被占用的端口是 22346,已是2万多的端口号,不太可能被其他人的其他程序占用。因此,可能是自己上一个进程跑完没有结束导致当前进程端口被占用。

    因此,只需要在执行完程序之后,(跑完工程之后),用命令杀掉端口的程序即可。

    macOS 系统在终端使用命令查看并杀除进程:

    ##  查看使用 端口 22346 的进程
    ➜  ~ lsof -i:22346
    COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
    node    55576 user   21u  IPv4 0x572d0cec2a30c695      0t0  TCP localhost:22346 (LISTEN)
    ##  杀掉使用appium的进程
    ➜  ~ ps -ef |grep 'appium'|grep -v 'grep'| awk '{print $2}'| xargs kill -2    (其实用这个即可)
    ##  杀掉PID为55576的进程
    ➜  ~ kill -9 55576
    kill: kill 55576 failed: no such process
     

     

  • 相关阅读:
    洛谷P2886 [USACO07NOV]Cow Relays G
    CF1344F Piet's Palette
    CF1344E Train Tracks
    CF1342F Make It Ascending
    LOJ6049 拍苍蝇
    test20200430 最长路径
    LG1742 最小圆覆盖 和 LOJ6360 复燃「恋之埋火」
    LOJ6358 前夕
    LOJ6485 LJJ学二项式定理
    LOJ2882 两个人的星座
  • 原文地址:https://www.cnblogs.com/shenxiaolin/p/14452423.html
Copyright © 2011-2022 走看看