# 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将自动尝试重新连接
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://socket.gitbook.io/docs/3-ke-hu-duan-apiclientapi/3.3-socket/event_disconnect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
