Sometimes it can take a long time for the board to connect.
I don't know if you have multiple boards, but if you do and the device_key and login_name don't match then that will cause a problem.
I see a wifi error of 3 but then it says connected but then MQTT fails on Error 5.
I just googled your issue and found another forum entry identical to yours. Here is the Link