I know this is way totoo late and a dollar short, but I have been searching for this for a long time and finally found the same problem. I have been wrestling with this for the past day. So I did the same thing and downgraded from 3.1.1 (I know this thread is 4 years old however).
What I just figured out, is it appears that if I uploaded the sketch with the 3.1.1 board installed and just let the soft reset do it's thing, I would get this same problem. If I did a hard reset pushing the reset button then the wifi connected worked as expected so in my case that soft reset after the upload was the culprit.