Connection Status and Attributes
After a connection is established, you can view connection details and status through the following attributes:
| Attribute | Type | Description |
|---|---|---|
| session_id | str | Current server session ID, automatically updated after reconnection or node switching. |
| host | str | Server address of the current connection; in high-availability mode, it reflects the node currently connected. |
| port | int | Server port of the current connection. |
| is_alive | bool | Actively sends a version() probe request to check
whether the connection is available. Incurs network overhead and may
trigger reconnection or node switching. |
| is_closed | bool | Indicates whether close() has been explicitly called
on the client object. Does not initiate network requests and cannot
reflect underlying network connectivity. |
| is_busy | bool | Indicates whether the connection is executing an operation or is still in the block read state. |
| startup | str | The startup script configured for the current connection. |
| msg_logger | dolphindb.Logger |
Custom message logger used to handle print outputs
from scripts. For details, see Other Features. |
-
Check connection availability: Use is_alive. is_closed only records whether the client object has been explicitly closed, and may still return False if the underlying socket is abnormally disconnected.
-
Block reading restriction: When an uncompleted
BlockReaderread is in progress (is_busy=True), reading is_alive raises aRuntimeError.
