小编Nor*_*rod的帖子

错误[ERR_STREAM_WRITE_AFTER_END]:结束后写入[使用socket.io的npm请求]

在我的服务器端,我监听套接字服务器,在我自己的笔记本电脑中,我具有socket.io-client服务,每当我打开它们时,它们都在连接。

当其他人向我的服务器请求时,服务器通过套接字将该请求发送到我的笔记本电脑,然后我的笔记本电脑使用npm-request从本地主机获取数据,并将返回的数据返回给服务器,然后服务器将信息显示给客户端。

这是我服务器端的错误:

/*

throw er; // Unhandled 'error' event
      ^

**Error [ERR_STREAM_WRITE_AFTER_END]: write after end**
    at write_ (_http_outgoing.js:572:17)
    at ServerResponse.write (_http_outgoing.js:567:10)
    at Socket.<anonymous> (/public_html/api/index.js:37:9)
    at Socket.emit (events.js:187:15)
    at /public_html/api/node_modules/socket.io/lib/socket.js:528:12
    at process._tickCallback (internal/process/next_tick.js:61:11)
Emitted 'error' event at:
    at writeAfterEndNT (_http_outgoing.js:634:7)
    at process._tickCallback (internal/process/next_tick.js:63:19)

    */
Run Code Online (Sandbox Code Playgroud)

服务器端代码:

/*

throw er; // Unhandled 'error' event
      ^

**Error [ERR_STREAM_WRITE_AFTER_END]: write after end**
    at write_ (_http_outgoing.js:572:17)
    at ServerResponse.write (_http_outgoing.js:567:10)
    at Socket.<anonymous> (/public_html/api/index.js:37:9)
    at Socket.emit (events.js:187:15)
    at /public_html/api/node_modules/socket.io/lib/socket.js:528:12
    at process._tickCallback (internal/process/next_tick.js:61:11)
Emitted 'error' event at:
    at …
Run Code Online (Sandbox Code Playgroud)

javascript request node.js socket.io npm-request

2
推荐指数
1
解决办法
6552
查看次数

标签 统计

javascript ×1

node.js ×1

npm-request ×1

request ×1

socket.io ×1