You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While developing an Android plugin for my Godot game, I ran into an issue with ADB reverse ports. My app uses Firebase emulator suite. Testing the auth functionality (and others too) requires the Godot game running on my real Android device (connected with ADB over USB cable) to communicate with the Firebase emulator suite running on my PC. This involves HTTP traffic, which should flow from the device to my PC. I could configure my PC's "real" IP address (like 192.168.1.2) to the game, so the device could find my PC via my router, but that would make things complicated, since my IP could change between development sessions. The way Firebase community suggests to deal with this is by reverse forwarding ports with ADB. This would allow the game to contact one of its local ports, which then would be forwarded to my PC. This has the benefit of not needing to configure a "real" IP address to the game. The only problem with this approach is that Godot's Android plugin kinda "captures" the forwarded ports when I deploy my game from Godot with Remote Debug. Basically when deploying the app, Godot removes all existing reverse port configurations from my device before deploying. This probably is done so that the debugger (which uses same ADB reverse port feature) is not being interfered with dangling port configs from previous deploys. What this also does, is effectively breaks the connectivity between the Game and Firebase emulator suite: if I use ADB to specify my Firebase reverse port configs before I deploy the game from Godot, Godot will clear those out on next deploy. I could technically add the configs back after the deploy has been completed, but this is cumbersome and does not work if I need to connect to the emulator suite on startup. To solve the issue, I made a small prototype to allow the developer to specify extra reverse ports in the Godot editor. I am not a C/C++ coder, so my implementation might be horrible, but I hope I could communicate my idea with it. I forked the Godot repo and made a small commit to illustrate this.
The commit includes an extra config in the editor settings and corresponding code in the Android plugin to execute the necessary ADB commands. The configurations would be made as comma-separated list of ADB reverse ports (connection type:port):
tcp:9099,tcp:9100
This would reverse two ports 9099 and 9100.
I struggled for a long time on whether the implementation should allow specifying both source and destination ports (instead just specifying port which would be used for both), but I ended up with an implementation which specifies just one port. My rationale for this is that most of the time, the developer is in control of those ports so they should always be able to have the same port running on the device and on the developer PC. The only thing I could think of breaking this assumption was that for some reason the developer would like to use a port on their PC which is reserved for something else on the Android device, or vice versa. However, allowing the developer to specify both ports would make the configuration a bit less self evident (in my opinion at least), and also a bit more error-prone since the config would be a bit more complex. But I think my decision here is highly debatable, I would welcome counter arguments. =)
Anyways, since I have never contributed to Godot before, I was not sure how to proceed with this. So I decided to start a discussion. =)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
While developing an Android plugin for my Godot game, I ran into an issue with ADB reverse ports. My app uses Firebase emulator suite. Testing the auth functionality (and others too) requires the Godot game running on my real Android device (connected with ADB over USB cable) to communicate with the Firebase emulator suite running on my PC. This involves HTTP traffic, which should flow from the device to my PC. I could configure my PC's "real" IP address (like 192.168.1.2) to the game, so the device could find my PC via my router, but that would make things complicated, since my IP could change between development sessions. The way Firebase community suggests to deal with this is by reverse forwarding ports with ADB. This would allow the game to contact one of its local ports, which then would be forwarded to my PC. This has the benefit of not needing to configure a "real" IP address to the game. The only problem with this approach is that Godot's Android plugin kinda "captures" the forwarded ports when I deploy my game from Godot with Remote Debug. Basically when deploying the app, Godot removes all existing reverse port configurations from my device before deploying. This probably is done so that the debugger (which uses same ADB reverse port feature) is not being interfered with dangling port configs from previous deploys. What this also does, is effectively breaks the connectivity between the Game and Firebase emulator suite: if I use ADB to specify my Firebase reverse port configs before I deploy the game from Godot, Godot will clear those out on next deploy. I could technically add the configs back after the deploy has been completed, but this is cumbersome and does not work if I need to connect to the emulator suite on startup. To solve the issue, I made a small prototype to allow the developer to specify extra reverse ports in the Godot editor. I am not a C/C++ coder, so my implementation might be horrible, but I hope I could communicate my idea with it. I forked the Godot repo and made a small commit to illustrate this.
You can access it here: jlundan/godot@9c94bf4
The commit includes an extra config in the editor settings and corresponding code in the Android plugin to execute the necessary ADB commands. The configurations would be made as comma-separated list of ADB reverse ports (connection type:port):
This would reverse two ports 9099 and 9100.
I struggled for a long time on whether the implementation should allow specifying both source and destination ports (instead just specifying port which would be used for both), but I ended up with an implementation which specifies just one port. My rationale for this is that most of the time, the developer is in control of those ports so they should always be able to have the same port running on the device and on the developer PC. The only thing I could think of breaking this assumption was that for some reason the developer would like to use a port on their PC which is reserved for something else on the Android device, or vice versa. However, allowing the developer to specify both ports would make the configuration a bit less self evident (in my opinion at least), and also a bit more error-prone since the config would be a bit more complex. But I think my decision here is highly debatable, I would welcome counter arguments. =)
Anyways, since I have never contributed to Godot before, I was not sure how to proceed with this. So I decided to start a discussion. =)
Beta Was this translation helpful? Give feedback.
All reactions