0

I've written a server application in node.js which receives inbound error messages from some hardware using socket.io and an RS232 wireless device.

My server has been receiving error messages perfectly for the past 2 months, but for the last 2 days the server has been randomly locking up and won't respond to any inbound messages until Ctrl + C is pressed in the terminal. I would normally expect this to shut the server down, but when the server blocks, Ctrl + C has been unblocking the event loop and then processing inbound messages that seemed to be queued whilst the event loop was blocked (this is only a theory).

I believe my theory to be correct because the console will hang at a message such as waiting for data... and then pressing Ctrl + C later will batch process 15 requests to push data to my back end.

Initially I can't spot any problems in my code and I'm more baffled due to the application running without problems for 2 months. My question here is, are there any easy to use profiling tools to see where exactly my server application is freezing?

4
  • Are you gracefully handling errors with 'if else' statements or 'try catch' blocks? Maybe the device sends an unusual response, at some point, and your scripts aren't accounting for that scenario, which could cause an error/block. Commented Feb 12, 2016 at 17:08
  • @Brett84c I use an exhaustive list of if/else on my socket.on('data', ... method. I don't use try/catch. However, when the data comes in I log the data thats in the buffer. When the server locks no buffer is printed but upon pressing Ctrl C it does. Commented Feb 12, 2016 at 18:18
  • Hmm, that is odd. Wish I could be of more help but i'm intermediate with Node, at best, and never directly worked with Socket.io (comes built into Meteor). When all else fails, console.log everything, heh. Commented Feb 12, 2016 at 19:24
  • 1
    @Brett84c thats what im currently doing, I'll update this question if I find a solution. Thanks for your input ;) Commented Feb 12, 2016 at 19:53

1 Answer 1

1

Maybe you can find the problem using flamegraphs http://www.brendangregg.com/flamegraphs.html. You can find more information here

Aditionally i recommend you to memory profile your application because problems appearing after some time is a common sign of that issue.

Sign up to request clarification or add additional context in comments.

1 Comment

Interesting, I'll try that out tomorrow and see what happens. Thankyou

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.