Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: manually start companion since idb connect cannot do it #20

Merged
merged 11 commits into from
Jan 7, 2020

Conversation

imurchie
Copy link
Contributor

Letting idb connect do the heavy lifting of starting the companion itself does not work. It almost always results in an error like

Could not connect to DADCC0FB-D5B3-49E6-8994-48FF3481FBD4:None.
            Make sure both host and port are correct and reachable

So start the companion and then connect to the port it starts on.

This also skips the tests for "describe device" since the underlying command does not support the JSON flag, and parsing the output is the task of another PR

$ idb describe --json --udid 98879B6B-DED0-42A6-83E8-FB0FD112BE47'
TargetDescription(udid='98879B6B-DED0-42A6-83E8-FB0FD112BE47', name='appium-idb-tests-7BE5D893-F449-4BB1-BC42-C879B8D0CD38', state='booted', target_type='simulator', os_version='iOS 12.2', architecture='x86_64', companion_info=CompanionInfo(udid='', host='', port=0, is_local=False), screen_dimensions=ScreenDimensions(width=750, height=1334, density=2.0, width_points=375, height_points=667))

@@ -72,9 +74,44 @@ systemCallMethods.connect = async function connect (opts = {}) {
}
}

let port = DEFAULT_COMPANION_PORT;
Copy link
Contributor

@mykola-mokhnach mykola-mokhnach Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work if the companion is already running?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works insofar as it kills the running companion.

try {
try {
await tpExec(IDB_EXECUTABLE, ['connect', this.udid]);
await tpExec(IDB_EXECUTABLE, ['connect', 'localhost', port]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it also listen on ipv6 (in case localhost is resolved to :::1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea about that. If it did for connections managed by idb then I imagine it does this way, too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean if netstat output shows the companion is only listening ipv4 then it is better to explicitly put 127.0.0.1 as the address

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it does

$ netstat -an -ptcp | grep LISTEN
tcp46      0      0  *.10882                *.*                    LISTEN
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants