The last service “simulator” is exposing port 14540 to the outside world that is being used by my app.
When I run the simulator in docker on my host machine and run the app on my host machine, everything works fine. But when I put these images in my docker-compose file and do the docker compose up, my app is working, celery, redis and simulator are also working. But simulator isn’t connecting with my app.
I corrected your title, as you mend container, but wrote image. Furthermore, please use a “preformated Text” block, instead of a quote block when posting code. This time I changed it for you.
If not specified, a published port will always use tcp, you need to explicitly specify it with /udp after the container port (see link above for details)
@meyay Thank you for all the help with the formating of my question.
As you suggested, I added the protocol to the port, but still no connection is made.
Here is the code after adding the protocol.
I tried adding the udp before also as I read this in an article, but this didn’t work (added the double quotes in the ports as suggested on the documenation link you gave).
After running the entire docker, I ran the netstat -tunlp on the simulator and app containers with the hope that it might help you give some more information that you can use to help me fix my problem. Output image is attached.
To share the maximum information, here is the code of my app source file which is using the simulator for connection:
app file:
#!/usr/bin/env python3
import asyncio
from mavsdk import System
async def run():
# Init the drone
drone = System()
await drone.connect(system_address="udp://:14540")
print("Waiting for drone to connect...")
async for state in drone.core.connection_state():
if state.is_connected:
print(f"-- Connected to drone!")
break
# Execute the maneuvers
print("-- Arming")
await drone.action.arm()
print("-- Taking off")
await drone.action.set_takeoff_altitude(10.0)
await drone.action.takeoff()
await asyncio.sleep(10)
print("-- Landing")
await drone.action.land()
if __name__ == "__main__":
# Run the asyncio loop
asyncio.run(run())
In my code I tried the following things, but none of them worked: Approach # 1-await drone.connect(system_address="udp://:14540") Approach # 2-await drone.connect(system_address="udp://localhost:14540") Approach # 3-await drone.connect(system_address="udp://simulator:14540") (name of the service)