Get First Message or Requesting First Message

Hello Community,
I am new to UAV field and its been almost two months, I have started my project for my bachelors degree. I currently at this stage where I am trying to build my own one window GUI where I want to look at only Sensors Data and send commands through user input. I have already read the basics but I am stuck where I have to wait for the heartbeat message,
I am using wait_heartbeat() method. When I start the Pixhawk 6 and directly run my code I am unable to receive first heartbeat and it keeps waiting at this line. I have connected TELEM1 Port to my PC using TTL to USB Convertor.
When I run the QGCS, It gets connected there and then I close QGCS and run the same code it starts receiving the first heartbeat and then rest of the mavlink messages.

Can anyone let me know how can I resolve this issue? I think QGCS might be sending that MAVLink requests but how can I achieve the same in mine?

You could look at how mavproxy does it: https://github.com/ArduPilot/MAVProxy/tree/master/MAVProxy