google / android-emulator-container-scripts

1.82k stars 256 forks source link

can't view the emulator on the web through webrtc #299

Open crazier opened 2 years ago

crazier commented 2 years ago

I have two servers A,B. Due to the network policy, B cannot be directly accessed through port 80 on the PC, but A can access all ports of B. And the PC can access A's 80 port.To view the android in the web, So I need to deploy an Nginx on machine A and route requests to machine B. Nginx is configured as follows:

But the function of webrtc does not work properly, the android.emulation.control.Rtc/receiveJsepMessages api reponse nothing . other API functions are normal. How to solve this?

Deploy the emulator steps in B machine:

  1. emu-docker interactive --start
  2. ./create_web_container.sh -p user1,passwd1,user2,passwd2,....

Add Nginx Config in A machine:

l`ocation /emulator { proxy_http_version 1.1; proxy_pass https://B_IP;

error_page 301 302 303 = @handle_redirect;

}

location /token {
    proxy_http_version 1.1;
    proxy_pass https://B_IP/token;
}

location /android.emulation.control.EmulatorController {
    proxy_http_version 1.1;
    proxy_pass https://B_IP/android.emulation.control.EmulatorController ;
    #error_page 301 302 303 = @handle_redirect;
}

location /android.emulation.control.Rtc {
    proxy_http_version 1.1;
    proxy_pass https://B_IP/android.emulation.control.Rtc;
}

location ^~ /static/ {
    proxy_http_version 1.1;
    proxy_pass https://B_IP/static/;
}`
crazier commented 2 years ago

add the turn server fix the issue follow this https://github.com/google/android-emulator-container-scripts/blob/master/js/turn/README.MD