How do I debug error ECONNRESET in Node.js?

后端 未结 14 1453
刺人心
刺人心 2020-11-22 04:02

I\'m running an Express.js application using Socket.io for a chat webapp and I get the following error randomly around 5 times during 24h. The node process is wrapped in for

14条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 04:28

    A simple tcp server I had for serving the flash policy file was causing this. I can now catch the error using a handler:

    # serving the flash policy file
    net = require("net")
    
    net.createServer((socket) =>
      //just added
      socket.on("error", (err) =>
        console.log("Caught flash policy server socket error: ")
        console.log(err.stack)
      )
    
      socket.write("\n")
      socket.write("\n")
      socket.write("\n")
      socket.write("\n")
      socket.write("\n")
      socket.end()
    ).listen(843)
    

提交回复
热议问题