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

Question: Connect to scrcpy server and send commands #1249

Closed
razumeiko opened this issue Mar 28, 2020 · 13 comments
Closed

Question: Connect to scrcpy server and send commands #1249

razumeiko opened this issue Mar 28, 2020 · 13 comments

Comments

@razumeiko
Copy link

Hi. First of all, thanks for such amazing app. It works really good.

I am writing python script which analyzes screen and depends on some events on the screen i need to send swipe events . My initial version was on ADB then socket to ADB server but it's slower than your version.

Currently i am using scrcpy to get live screen and i want to send events through scrcpy, i am trying to open socket connection to scrcpy server but no luck.
Is it accessible? Is it right server address: 127.0.0.1:27183?
Do i need to do any specific actions to open socket connection with your server? I tried to learn how you do it but it looks like you just open LocalSocket by name and that's it, maybe there is limit on number of connections?
Also if it's possible to reuse your connection, could you point please, quick example how to build request to do input action? swipe for example.

Thanks.

@rom1v
Copy link
Collaborator

rom1v commented Mar 28, 2020

The whole thread #129 should help you.

@razumeiko
Copy link
Author

@rom1v i checked it and tried to repeat it but looks like it's little bit different from what i need. In example he run server separately on mobile but i need to run regular client + server + my script.

When i tried to forward internal port and connect i receive empty string in response but connected succesfully, when i try to connect to same port as scrcpy do, i receive timeout, it looks like server can't handle multiple connections?

@razumeiko
Copy link
Author

razumeiko commented Mar 29, 2020

I just realized that i don't need client running, i can get everything from server, i was trying to run server with

adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.12 0 8000000 30 true

But i get "Aborted" all the time. Tried to play with arguments but no luck. I am on Android Q, Pixel 3a, is this something with access rights? How can i debug it?

@razumeiko
Copy link
Author

It turns out that server file removed after run and i had wrong params. Fixed now and server works. Thanks!

@rxydenxd
Copy link

It turns out that server file removed after run and i had wrong params. Fixed now and server works. Thanks!

(noob alert) can you tell me what were the wrong parameters?

@razumeiko
Copy link
Author

razumeiko commented Jul 27, 2020

@rxydenxd in new versions of server there are more params, here is my final code
com.genymobile.scrcpy.Server 1.12.1 1024 8000000 30 true - false true

@rxydenxd
Copy link

rxydenxd commented Jul 27, 2020

copied your code

com.genymobile.scrcpy.Server 1.12.1 1024 8000000 30 true - false true

still no luck. how to find what parameters are right for me?

@razumeiko
Copy link
Author

@rxydenxd i was looking at source code of server and checking what arguments it takes.

@rxydenxd
Copy link

It turns out that server file removed after run

I guess it has something to do with this?

@razumeiko
Copy link
Author

@rxydenxd you are using python for getting this work?

@rxydenxd
Copy link

rxydenxd commented Jul 27, 2020

@rxydenxd you are using python for getting this work?

yes brother, i cant even get the adb part to work :(

C:\Users\rxydenxd\Desktop\scrcpy-win64-v1.14>adb shell CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.14 0 8000000 30 true - false true
adb server version (39) doesn't match this client (41); killing...
* daemon started successfully
Aborted

@rom1v
Copy link
Collaborator

rom1v commented Jul 27, 2020

adb server version (39) doesn't match this client (41); killing...

https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#conflicts-between-adb-versions

@razumeiko
Copy link
Author

@rxydenxd you can check usage example here https://github.com/razumeiko/py-android-viewer

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

No branches or pull requests

3 participants