I’m using the Google Chrome Developer Tools plugin for Eclipse to debug my Node.js server. This server uses Socket.io for the websocket connection between my web client and the server. The problem comes when I set a breakpoint in my server and start stepping through the code. The client soon decides the server isn’t there anymore because there’s no longer a heartbeat or any communication, so it disconnects. Meanwhile, as I’m stepping through, my code tries to do something with the socket and then it dies since the socket is now shutdown. It makes it a bit tricky trying to debug like this.
So the question is, how can I debug a server like this with an open websocket connection and not close the connection? I don’t know that there’s a good solution, but I thought I’d put it out there and see if anyone has a genius idea.
After doing more research I discovered a couple different projects that looked hopeful, namely ‘node-inspector’ and ‘node-codein’. However, node-inspector doesn’t work with the latest versions of node, and node-codein has a lot of bugs. Also, neither is really maintained and they both only work with Chrome. So, I wrote my own solution, called Node Monkey, which is really simple to use and it works with Firefox or Chrome. It simply captures things logged to the console in your Node app and redirects that output to the browser console. You can install it by running: