Blog

05
March 2015

Gavin Pickin

Did you turn it off and on again? Troubleshooting Gotchas with Cordova and WebSQL

Chit Chat, Mobile Development, Techie Gotchas, WebSQL

If you have not seen IT Crowd, you are missing out on some strange but funny geek culture... and one of the highlights of that show is the line, "Did you turn it off and on again". Sometimes with troubleshooting, the simple things can throw you off, and that happened with me recently, so I wanted to share my frustration. This might not be the most informative post, but hopefully it helps someone, so they don't shoot themselves, like I was tempted to do so.

Of course, this might start a flame war, but those mac users know, turn it off and on again usually refers to a Windows machine, and that's what I had to use, again. I am working on this cross platform app, so the fun came when it was time to make sure everything was still working on windows 8. Short answer was NO NO NO NO NO.

First things first, it is a cordova app, using Visual Studio Express 2013 (although I need to get the Free Community Full Featured Version soon) and the Cordova CLI. With cross platform, I put all my files in dropbox, so it could sync behind the scenes, and life would be good. I spin up windows, go get a drink, make that 2, come back and check dropbox was synced, do a fresh build for windows

cordova build windows

Open the project in Visual Studio, and then run to my Surface (ok its not my surface, its the one I stole from my wife's college bag when she wasn't looking). Debugging shows an error... great, so no login screen, straight into an error. I'm feeling good, lets see what it is.

Connection ID not set

Now, this error was pulling up inside the plugin files itself. Strange. Searching on the google, its a very weird bug, and nothing to do with cordova, or the msopentech websql plugin. I am completely lost. I turn off everything talking to the database, and no error, turn on any database talking code, except the connection, and it throws the same error. Since the error discussed the connection, I throw the first DB call after the db.openDatabase into a setTimeout and make it wait for 10 seconds, overkill, to make sure the connection is made. No problem there, until the function runs, and then the same error.

In a frustrated growl, I decided I would removed and re-add the plugin, and remore and re-add the platform in cordova, to force the latest versions of the files.

Build and run, and boom - another error I solved earlier. The cordova platform for windows included an expired cert.
yourCordovaProject\platforms\windows\CordovaApp_TemporaryKey.pfx
There is a stack overflow question here http://stackoverflow.com/questions/26874331/multi-device-hybrid-app-fails-to-build-the-certificate-specified-has-expired and links to MS Open Tech Site where you can download a new file to replace the old one. https://msopentech.com/blog/2014/11/11/cordova-certificate-issue-were-working-on-it/
Download and replace that, and build, and run... and wait for the error.

GONE!!!

What? How did my App get messed up?
I have no clue, all I know is, sometimes you need to uninstall and reinstall, and it magically fixes everything. Maybe it was a new version, which I doubt, since I was checking version numbers. Maybe dropbox sync failed and a file got out of whack.

I don't know, but I was happy... its working right.

Looking at my login screen, I login, and boom. The whole app dies. Not a debugging error, with the dreaded break or continue. No... just boom dead. I comment out pieces, try to step through code. After battling the last problem, I say screw it... I'm shutting down Visual Studio, I'm going to reboot the machine.

I got kick some walls, flip some tables, attack a few villages, have a drink, and when windows comes back up... I cordova build windows, open Visual Studio, run and ta-daa, I see the real error. No more app crashing without control, I get the normal break / continue debug issue, and now, I can figure out whats wrong.

I assume Visual Studio's project wasn't refreshed after adding and removing the platform, or something, but turning it off, and on again fixed it.
Now, after my day is done, I'm back where I started, with the error I was planning to fix for the day.

Moral of the story.
If something doesn't make sense, uninstall reinstall. If it still makes no sense. Turn it off and on again.

Happy debugging everyone :)

 

Blog Search