=============== LIBRARY RULES =============== From library maintainers: - Target Go 1.22.x - Use gorilla/websocket for WebSocket transport - Provide automatic reconnection with configurable backoff (min, max, factor, type) - Apply persistent, production-ready backoff across all reconnection scenarios and reset after stable connections - Support subscription resumption and message queueing on reconnect - Implement heartbeat via ping/pong with configurable intervals and timeouts - Expose event callbacks for onConnected, onReconnecting, and onError ### Install resilientws Package Source: https://github.com/ipanardian/resilientws/blob/main/README.md Install the resilientws library using go get. ```sh go get github.com/ipanardian/resilientws ``` -------------------------------- ### Basic Configuration and Connection Source: https://github.com/ipanardian/resilientws/blob/main/README.md Configure and establish a basic resilient WebSocket connection. Handles connection, reconnection, and error events. ```go ws := &resilientws.Resws{ RecBackoffMin: 1 * time.Second, // Minimum backoff duration RecBackoffMax: 30 * time.Second, // Maximum backoff duration RecBackoffFactor: 1.5, // Backoff multiplier BackoffType: resilientws.BackoffTypeJitter, // Backoff strategy MessageHandler: func(msgType int, msg []byte) { log.Printf("Received: %s", string(msg)) }, } ws.OnConnected(func(url string) { log.Printf("Connected to %s", url) }) ws.OnReconnecting(func(duration time.Duration) { log.Printf("Reconnecting in %v", duration) }) ws.OnError(func(err error) { log.Printf("Error: %v", err) }) ws.Dial("wss://example.com/ws") defers ws.Close() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.