Reputation: 311
I decided to try using Weinre to help me debug a Cordova application I'm trying to build for Windows Phone 8; sadly, I've run into an odd issue where the Windows Phone 8 Emulator can connect to my local weinre config and then after a few seconds disappears... I tried this on another windows 2012 and I seem to be encountering the same thing. I even tried with a base Cordova template.
So, when I debug my application from VS2012, the emulator starts and the application deploys. I know that I can't use LOCALHOST, so my script reference is to the IP address of my computer or server. The apps starts, and I can go to the Weinre console and I see that I have a connection. But after a few seconds the connection vanishes. It seems like the Emulator cannot maintain a constant connection to weinre... Is there some kind of bandwidth limitor on the emulator that cuts my connection? Is there a better way to remote debug Win Phone 8 apps that I should be using instead?
UPDATE: I also tried this from my Nokia 920, and I see the same thing happens...
Upvotes: 1
Views: 1279
Reputation: 2623
UPDARE
Weinre was patched and should work correct now. I recommend to try the latest version from npm https://npmjs.org/package/weinre
npm install -g weinre
weinre --boundHost -all-
ORIGINAL ANSWER
It seems Cordova specific XHR patch breaks weinre logic. I see js errors in target script.
I've added a quick fix to weinre target-script.js so you can replace \target\target-script.js (or target-script-min.js) with the following file and it should work
http://dl.dropbox.com/u/23085338/weinre-target-script-min-patched.js
IMPORTANT. Weinre js must be added before cordova.js
But I would recommend the following super easy way to connect weinre to your page w/o any local setup required - just add this to your page
<script type="text/javascript">
window.WeinreServerId = "wp_test"; // <-- your unique identifier on the server below
window.WeinreServerURL = "http://debug.phonegap.com"; // <-- weinre server to use
// To open debugger use the following uri format - WeinreServerURL/client/#WeinreServerId
// for example http://debug.phonegap.com/client/#wp_test
</script>
<script type="text/javascript" src="http://dl.dropbox.com/u/23085338/weinre-target-script-min.js"></script>
For the general troubleshooting see Windows Phone 8 IE10 Javascript debugging
UPDATE
Another quick fix that should work is to replace (at target-script-min.js or target-script.js)
xhr = new XMLHttpRequest();
with
xhr = (XMLHttpRequest.noConflict ? new XMLHttpRequest.noConflict() : new XMLHttpRequest());
Upvotes: 1