There is no concept of connection, it’s just shouting in to the void and hoping something hears it.
To that end, can you tell us what the RSSI & SNR is of the Join Accept and report back - that will inform us of how hard the LoRa Bee can shout - it it’s too high or too low it may then have issues hearing the response from the gateway due to it having a really small antenna.
You should be aware that the code you have posted breaks both the FUP and very probably the legal limits (
) - please review the FUP in the Learn section (linked above) and reassure us that you are on top of this aspect, particularly the number of downlinks you can do a day.