NetDebug - HTTP Based Debugging monitor
Features
- Free
- Supports multiple clients at once. Monitor clients and server side of systems at the same time.
- Runs independently of the browser. NetDebug doesn't stop running when the browser is restarted.
- Can be used to debug browser extensions, web pages, server and client code, desktop software and even mobile apps.
- No onscreen coding or popups required to view messages. Messages go to a separate application.
- Messages can be color coded and IP addresses displayed.
- NetDebug has been tested on Windows 2000 and Vista and should work with other versions.
- Works with any network capable language.
About the program
This program was created to simplify client server development of browser extensions, but can be used in any debugging, monitoring, or alerting
scenario. Messages are sent over HTTP protocol using simple GET requests.
NetDebug receives message set over a TCP/IP port as HTTP GET requests. It parses parameters and displays the results as a message in a console.
In PHP, this is as simple as:
file_get_contents("http://127.0.0.1/?msg=Hello+World");
More coding examples are displayed below.
Advantages over error consoles
NetDebug runs independent of your application and development environment. It can run on the same computer, or on a separate computer. So you
can setup NetDebug and leave it running thru browser or computer restarts.
NetDebug can be used to monitor programs from multiple clients, so you can monitor both the client and server sides of a web interaction
on a single debug console. You may also run copies of NetDebug on one machine on different ports. Simple color coding parameters allow for
easy differentiation of clients by color. The color parametes can also be used to indicate message priority, application section, or any other
color meaning you desire.
Install/Uninstall
To install, download it to your desktop or USB key. To uninstall, delete it from your desktop or USB key. No registry or ini files are used.
Running on a different port
If you want to run on a port other than port 80, you can pass the port number when you call the program. "netbug 25000" will open the program
from a command line with port 25000. You can also create a shortcut on your desktop to do this. The operating port is displayed on the main
screen.
If you are using a Windows firewall, or a desktop firewall application, or if your application is across a firewall, be sure to open the port
you intend to use at the firewall.
Sending debug messages from JavaScript
Messages are passed via HTTP using the XMLHttpRequest mechanism. Paste the following function into your code. Then change the IP address to
point to the computer that will run NetDebug. Use 127.0.0.1 if you are running NetDebug on the same machine where your script is running.
function debugMon(msg){
var targetIP = "192.168.0.3"; // change this to point to the machine running NetDebug
try {
httpRequest = new XMLHttpRequest();
}
catch(e) {
return;
}
if(msg=="clear"){
httpRequest.open("GET", "http://" + targetIP + "?clear", true);
} else {
httpRequest.open("GET", "http://" + targetIP + "?msg=" + msg, true);
}
httpRequest.send(null);
}
To send a diagnostic message to NetDebug add a line to your code with the message to send. Here are some examples:
debugMon("itemClick idx:" + deck.selectedIndex);
debugMon("starting program....");
To send a message in color, append the color tag and color name to your message:
debugMon("itemClick idx:" + deck.selectedIndex + "&color=blue")
debugMon("starting program...." + "&color=red");
To clear the screen, send "clear"
Sending debug messages from PHP is even easier.
<?php
file_get_contents("http://127.0.0.1/?msg=Hello+from+PHP");
?>
With this technique, and using a fixed IP or a DynDNS.org account, you can even have your production web server send you realtime alerts of certain events.
Sending debug messages from VBScript or WSH
Here's a VBScript examples that will work in wscript or cscript or any other VBScript capable shell. Similar technique can be used from VBA.
Set objHTTP = CreateObject("WinHTTP.WinHTTPRequest.5.1")
objHTTP.open "GET", "http://192.168.0.3/?msg=Hello+World", False
objHTTP.send
Sending debug messages from batch files.
To send messages from a batch file, use a command line HTTP tool like GNU wget
to issue the HTTP GET request. Powershell users may be interested in Get-Web
wget -o nul: http://127.0.0.1?msg=Hello+World
Sending debug messages from HTML
For simple alert-on-load needs, you can just use the HTML img tag to issue a message to NetDebug:
<img src="http://127.0.0.1/?msg=Hello+World" height=1 width=1><BR>
Sending debug messages from Other environments
Any language that can issue a HTTP GET or POST can send messages to the NetDebug console. You need send the URL request in the correct format.
For generic activity logging, consider using a syslog program instead.
http://127.0.0.1/?clear
http://192.168.200.3/?clear
http://127.0.0.1/?msg=Test+Message
http://127.0.0.1/?msg=Test+Message&color=red
Terms of Use
Use at your own risk. No warranty is implied or offered. You assume all liability for your use of this program including misuse, bugs, etc. Backup your system before
use.
Download
netdebug.zip Version 1.4 Apr 2010
Known Bugs
None.
Releases
1.4 - Apr 2010 - Move code samples to separate form. Better resize handling.
1.3 - Jan 2010 - Cosmetic tweaks to the main screen, added on screen code samples.
1.1 - Jun 2009 - Added mutex to prevent threads from stepping on each other's color coding in high speed situations
1.0 - Jun 2009 - Initial Release
Updated 18 Jan 2010
Article ID: debugging_php_and_debugging_javascript_code