DeviceFarmer / stf

Control and manage Android devices from your browser.

Home Page:https://devicefarmer.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why can only 25 devices be available at all times?

qianmianyao opened this issue · comments

I have a total of 33 devices connected, but only 25 can be available at all times. If I connect the 26th device, it stays in 'preparing' status. What is the reason for this? Is it something that needs to be configured, or is it a hardware issue?

46145e90432b7643cf02888a294bb60

945a83f3a4643392821764102cf9859

I can confirm it's not a problem with the phone, because if I unplug one of the 25 devices that are working, then the device in 'preparing' status becomes usable

@qianmianyao I see the Location property is the same for all devices, so it's probably a hardware issue of your motherboard which must be limited in the number of USB channels it can handle at the same time, you need to check this out! Do you also use USB hubs to connect your devices to your main machine? What is the topology? If you deployed STF in local mode, which is not recommended, you should instead deploy it in full deployment mode (cf. DEPLOYMENT.md), which will allow you to distribute your devices across many provider machines!

@qianmianyao I see the Location property is the same for all devices, so it's probably a hardware issue of your motherboard which must be limited in the number of USB channels it can handle at the same time, you need to check this out! Do you also use USB hubs to connect your devices to your main machine? What is the topology? If you deployed STF in local mode, which is not recommended, you should instead deploy it in full deployment mode (cf. DEPLOYMENT.md), which will allow you to distribute your devices across many provider machines!

I am indeed using the local mode, and this error occurs when connecting to the 26th phone.

stf        | 2023-09-15T07:11:49.122Z INF/device:plugins:screen:stream 1547 [ce12160c931820a00c] Starting WebSocket server on port NaN
stf        | 2023-09-15T07:11:49.124Z FTL/device 1547 [ce12160c931820a00c] Setup had an error RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received NaN.
stf        |     at new NodeError (node:internal/errors:372:5)
stf        |     at validatePort (node:internal/validators:217:11)
stf        |     at Server.listen (node:net:1508:5)
stf        |     at new WebSocketServer (/app/node_modules/ws/lib/WebSocketServer.js:76:20)
stf        |     at createServer (/app/lib/units/device/plugins/screen/stream.js:443:17)
stf        |     at /app/lib/units/device/plugins/screen/stream.js:467:12
stf        |     at SerialSyrup.ParallelSyrup.invoke (/app/node_modules/@devicefarmer/stf-syrup/lib/parallel.js:54:24)
stf        |     at /app/node_modules/@devicefarmer/stf-syrup/lib/serial.js:43:33
stf        |     at tryCatch1 (/app/node_modules/@devicefarmer/stf-syrup/node_modules/bluebird/js/main/util.js:63:19)
stf        |     at Promise$_callHandler [as _callHandler] (/app/node_modules/@devicefarmer/stf-syrup/node_modules/bluebird/js/main/promise.js:708:13)
stf        |     at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/app/node_modules/@devicefarmer/stf-syrup/node_modules/bluebird/js/main/promise.js:724:18)
stf        |     at Promise$_settlePromiseAt [as _settlePromiseAt] (/app/node_modules/@devicefarmer/stf-syrup/node_modules/bluebird/js/main/promise.js:896:14)
stf        |     at Promise$_fulfillPromises [as _fulfillPromises] (/app/node_modules/@devicefarmer/stf-syrup/node_modules/bluebird/js/main/promise.js:1041:14)
stf        |     at Async$_consumeFunctionBuffer [as _consumeFunctionBuffer] (/app/node_modules/@devicefarmer/stf-syrup/node_modules/bluebird/js/main/async.js:74:12)
stf        |     at Async$consumeFunctionBuffer (/app/node_modules/@devicefarmer/stf-syrup/node_modules/bluebird/js/main/async.js:37:14)
stf        |     at processTicksAndRejections (node:internal/process/task_queues:78:11)
stf        | 2023-09-15T07:11:49.125Z FTL/util:lifecycle 1547 [ce12160c931820a00c] Shutting down due to fatal error

@qianmianyao I see the Location property is the same for all devices, so it's probably a hardware issue of your motherboard which must be limited in the number of USB channels it can handle at the same time, you need to check this out! Do you also use USB hubs to connect your devices to your main machine? What is the topology? If you deployed STF in local mode, which is not recommended, you should instead deploy it in full deployment mode (cf. DEPLOYMENT.md), which will allow you to distribute your devices across many provider machines!

stf | 2023-09-15T07:19:50.885Z INF/provider 49 [*] Providing all 25 of 26 device(s); ignoring "988626464957315345"

@qianmianyao , please show the stf local.. command as well as the logs while it is launching ?

@qianmianyao , please show the stf local.. command as well as the logs while it is launching ?

I deployed through docker, and below is docker-compose

 stf local --adb-host adb --public-ip 192.168.9.3 --provider-min-port 7400 --provider-max-port 7500 --group-timeout 600 --no-cleanup
version: "3"

services:
  rethinkdb:
    container_name: rethinkdb
    image: rethinkdb:2.4.2
    restart: unless-stopped
    command: "rethinkdb --bind all --cache-size 2048"
    volumes:
        - "/opt/stf/rethinkdb-data:/data"

  adb:
    container_name: adb
    image: devicefarmer/adb:latest
    restart: unless-stopped
    volumes: 
      - "/dev/bus/usb:/dev/bus/usb"
    privileged: true

  stf:
    container_name: stf
    image: devicefarmer/stf
    ports:
      - "7100:7100"
      - "7110:7110"
      - "7400-7500:7400-7500"
    environment:
      - TZ='America/Los_Angeles'
      - RETHINKDB_PORT_28015_TCP=tcp://rethinkdb:28015
      - STF_ADMIN_EMAIL=123@gmail.com
      - STF_ADMIN_NAME=admin
      - STF_ROOT_GROUP_NAME=moren
    restart: unless-stopped
    command: stf local --adb-host adb --public-ip 192.168.9.3 --provider-min-port 7400 --provider-max-port 7500 --group-timeout 600 --no-cleanup
    
volumes:
  rethinkdb-data: {}

@qianmianyao you set the options --provider-min-port 7400 and --provider-max-port 7500 but each device takes 4 ports so only 25 devices can connect with these values, so you need to adjust these options , for example, if you want 100 devices to be able to connect, you would set --provider-min-port 7400 and --provider-max-port 7799

@qianmianyao you set the options --provider-min-port 7400 and --provider-max-port 7500 but each device takes 4 ports so only 25 devices can connect with these values, so you need to adjust these options , for example, if you want 100 devices to be able to connect, you would set --provider-min-port 7400 and --provider-max-port 7799

Thank you very much for your response, the issue has been resolved, many thanks.