Unable to join ttn. Gateway receive the message

Good spot!

To cut to the chase, are you using a Single Channel Packet Forwarder? If so, they cause issues for both the developer (as you’ve found) and for the community and are not supported on TTN. See: