How to run 2 Parallel devices with appium

I use wdio

  1. I have to connect 2 android devices
  2. Run two different script in 2 devices

I have capabilities like:
{ mjpegServerPort: 9202,
systemPort: 8202,
maxInstances: 1,
appiumVersion: ‘1.16.0’,
platformName: ‘Android’,
platformVersion: ‘5.1.1’,
deviceName: ‘…’,
{ mjpegServerPort: 9203,
systemPort: 8203,
maxInstances: 1,
appiumVersion: ‘1.16.0’,
platformVersion: ‘6.0.1’,
deviceName: ‘…’, }
… ]
config.maxInstances = 2;

When I started script I had two parallel .
[00:56:00] COMMAND POST “/wd/hub/session”
[00:56:00] DATA {“desiredCapabilities”:{“javascriptEnabled”:true,“locationContextEnabled”:true,“handlesAlerts”:true,“rotatable”:true,“mjpegServerPort”:9202,“systemPort”:8202,“maxInstances”:1,“appiumVersion”:“1.16.0”,“platformName”:“Android”,“appPackage”:"r…
[00:56:00] COMMAND POST “/wd/hub/session”
[00:56:00] DATA {“desiredCapabilities”:{“javascriptEnabled”:true,“locationContextEnabled”:true,“handlesAlerts”:true,“rotatable”:true,“mjpegServerPort”:9203,“systemPort”:8203,“maxInstances”:1,“appiumVersion”:“1.16.0”,“platformName”:“Android”,“appPackage”:…

But a first script run to both devices, and then a second script too.

I want: a first test run to a first device, a second test run to a second device

Please help find a solution

it is mandatory to set udid capability for each device.

I add it, but it not fix my problem (

There’s nothing more to say without the detailed server logs

here do not need logs (
Fundamentally, the apium is configured are two devices (not semmetric), then it runs one test in parallel on two devices.

I need to distribution tests between devices.