LingYanSi / blog

博客
https://github.com/LingYanSi/blog/issues
9 stars 0 forks source link

Error: read ECONNRESET #148

Open LingYanSi opened 2 years ago

LingYanSi commented 2 years ago
  Error: read ECONNRESET       
             at TCP.onStreamRead (internal/stream_base_commons.js:209:20)

https://stackoverflow.com/questions/17245881/how-do-i-debug-error-econnreset-in-node-js

"ECONNRESET" means the other side of the TCP conversation abruptly closed its end of the connection. This is most probably due to one or more application protocol errors. You could look at the API server logs to see if it complains about something.

今天遇到这个问题:排查一圈发现是因为在html的script标签中指定了crossorigin="anonymous"

但是服务端在处理script的资源请求时,没有在response header中添加允许跨域的标识,浏览器关闭了链接,导致服务端错误

以上仅是本质原因的一个实际场景表现