Hi I am developing an app using android emulator. I need to register a UDP socket at some port X that can be accessible from local network. Since Android emulator is NAT'd so I need port forwarding. I followed this post "Reaching a network device by IP and port using the Android emulator". It shows that I need to use
adb forward tcp:localPort tcp:emulatorPort
but this scheme doesn't work for udp (If anyone knows its version for UDP then please let me know). For UDP I found another solution that I need to telnet to adb port as follows (My adb is running at port 5037)
telnet localhost 5037
and redirect UDP port using redir command
redir add udp:36963:36963
But when I telnet it gives the following error
telnet 127.0.0.1 5037
Connecting to 127.0.0.1:5037...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Connection closed by foreign host.
I tried a lot to find any solution for this but fruitless.
I need to know any solution for accessing emulator from outer network.
Any call to 127.0.0.1:8085 from your Android test device will be forwarded to the development machine's port 8080. The port forward is active as long as chrome://inspect/#devices tab is open. Note that you might need to launch Chrome on the test device to initially activate the port forwarding.
The Android Debug Bridge (adb) tool provides port forwarding, an alternate way for you to set up network redirection. For more information, see Forwarding Ports in the adb documentation.
The ADB way. You can tell ADB to forward a test device port to a development machine port. adb reverse tcp:8085 tcp:8080. That's it. Any call to 127.0.0.1:8085 from your Android test device will be forwarded to the development machine's port 8080. Just keep your local running server running to reply to the connection request.
Any call to 127.0.0.1:8085 from your Android test device will be forwarded to the development machine's port 8080. Just keep your local running server running to reply to the connection request. These redirections are active as long as the device is connected. When you disconnect your device you would need to run these commands again.
The typical telnet port for the first emulator is 5554.
Try:
telnet localhost 5554
Then you'll need to authenticate, the instructions are printed in the console. It should be something like copy the value from $HOME/.emulator_console_auth_token without the trailing '%'.
auth <auth_token>
redir add udp:36963:36963
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With