> For the complete documentation index, see [llms.txt](https://socket.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://socket.gitbook.io/docs/3-ke-hu-duan-apiclientapi/3.3-socket/event_disconnect.md).

# 3.3.17 event:disconnect

* `reason` (String) "io server disconnect(IO服务器断开)","io client disconnect’ (IO客户端断开)","ping timeout (ping 超时)"

断开时触发

```javascript
socket.on('disconnect',(reason)=>{
    if(reason==='io server disconnect'){
        // 断开连接是由服务器启动的，需要手动重新连接
        socket.connect()
    }
    // 否则，socket将自动尝试重新连接
})
```
