Very simple Node.js client throws error ENOBUFS after many http requests

前端 未结 1 2023
醉梦人生
醉梦人生 2020-12-17 22:02

I have the following set up:

A node.js client makes end-to-end requests to a node.js server. After less than a minute, the client fails with error ENOBUFS.

相关标签:
1条回答
  • 2020-12-17 22:20

    The issue appears to be a problem with the Node.js HTTP client connection pool.

    If you add the option agent:false to the options argument of the http.request() function it will disable connection pooling and have each request use the header Connection: close. This change seems to allow the client code to run indefinitely.

    var options = {agent:false, host:"localhost", port:1337, /*...*/ };
    

    Doing this will degrade the performance of the HTTP clients and you should see frequent pauses in the client process (presumably while the V8 runtime does garbage collection). But it does seem to solve your problem!

    Per @joshp's comment, see if this issue has been addressed in a later version of Node.js or consider filing a bug report.

    0 讨论(0)
提交回复
热议问题