I have built a plugin that fires an Ajax call to connect to a third-party API. That API returns some Json, which I then save as a custom post with wp_insert_post
.
Now, usually, this works. But, now and again, the save fails, with a "MySQL server has gone away" error. I'm assuming this is because the API took too long to respond (maybe 30 secs), and so the connection closed.
Does this sound like the correct conclusion? And if so, how can I handle this from within the plugin?
EDIT: 20 secs doesn't seem long enough for a timeout, so I'm baffled by this one...