WebSocket
Use net.ws(url, options) for a single exchange; it closes after the first complete message. Use net.connect(url, options, callback) for continuous messages; the callback receives (socket, event) where event is open/message/retry/error/close.
Content and closing
content is text; binary data arrives as Java byte[], Python bytes or QuickJS Uint8Array. Send with the provided socket.send(), close with socket.close(), and use cancel to interrupt immediately. Connections are also cancelled when the site or session is released.
Timeouts and keepalive
timeoutlimits connection establishment only.pingis the protocol Ping interval in milliseconds.idleis the timeout for receiving no text/binary message; 0 (the default) disables it. Sending messages and Ping/Pong do not reset the deadline.- Platform subscriptions and application-level heartbeats belong to the spider; only set
idlewhen the source guarantees ongoing traffic.
Reconnection
reconnect: true enables reconnection (off by default); the wait starts at 1 second and doubles up to 30 seconds. Resubscribe on every open; on retry stop heartbeats and drop leftover packets. No reconnect happens after a deliberate close, release, or auth/certificate/protocol/callback errors.
Related
- Live danmaku: Live danmaku
- Cancellable waits:
sleepin Cache and storage