pywebsockets

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandshakeError

func HandshakeError(resp *http.Response, err error) error

Dial error as websockets connect raises it, a refused upgrade naming the HTTP status it got

func IsClosedOK

func IsClosedOK(err error) bool

Whether an error is the clean closure that ends iteration over a connection without raising

Types

type Close

type Close struct {
	Code   int
	Reason string
}

Close frame of one side of a closing handshake

func (Close) String

func (c Close) String() string

Code with its explanation and the reason when present, as websockets prints a close frame

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

One open client connection with its close record, reader and keepalive

func Connect

func Connect(ctx context.Context, rawURL string, opts ConnectOptions) (*Conn, error)

Opens a client connection the way websockets connect does, the opening handshake bounded by the open timeout

func (*Conn) Close

func (c *Conn) Close()

Runs the closing handshake with code 1000 bounded by the close timeout, then drops the TCP connection

func (*Conn) Open

func (c *Conn) Open() bool

Whether the connection has not ended yet

func (*Conn) Ping

func (c *Conn) Ping() error

Sends one ping frame with a random payload, ConnectionClosed when the connection already ended or the write fails

func (*Conn) Recv

func (c *Conn) Recv(ctx context.Context) (any, error)

Next message, a text frame as a string and a binary frame as bytes, ConnectionClosed once the connection ended

func (*Conn) Send

func (c *Conn) Send(message string) error

Sends one text frame, ConnectionClosed when the connection already ended or the write fails

func (*Conn) SendBytes

func (c *Conn) SendBytes(message []byte) error

Sends one binary frame, ConnectionClosed when the connection already ended or the write fails

type ConnectOptions

type ConnectOptions struct {
	OpenTimeout        time.Duration
	CloseTimeout       time.Duration
	PingInterval       time.Duration
	PingTimeout        time.Duration
	MaxSize            int64
	HappyEyeballsDelay time.Duration
	// Keepalive pings off, the ping_interval None of websockets connect
	NoKeepalive bool
}

Keyword arguments of websockets connect, a zero field taking the library default

type ConnectionClosed

type ConnectionClosed struct {
	Rcvd, Sent   *Close
	RcvdThenSent bool
}

Interaction with a closed connection, carrying the close frames received and sent and their order

func (*ConnectionClosed) Error

func (e *ConnectionClosed) Error() string

func (*ConnectionClosed) PyTypeName

func (e *ConnectionClosed) PyTypeName() string

ConnectionClosedOK when both frames carry a clean code, ConnectionClosedError otherwise

type DialError

type DialError struct{ Text string }

Failed TCP connect carrying the str of the OSError asyncio create_connection raises

func (*DialError) Error

func (e *DialError) Error() string

func (*DialError) PyTypeName

func (e *DialError) PyTypeName() string

type InvalidStatus

type InvalidStatus struct{ StatusCode int }

Handshake the server answered with a non 101 HTTP status, the websockets InvalidStatus exception

func (*InvalidStatus) Error

func (e *InvalidStatus) Error() string

func (*InvalidStatus) PyTypeName

func (e *InvalidStatus) PyTypeName() string

func (*InvalidStatus) Unwrap

func (e *InvalidStatus) Unwrap() error

type InvalidURI

type InvalidURI struct{ URI, Msg string }

URI the client refuses before dialing, the websockets InvalidURI exception

func (*InvalidURI) Error

func (e *InvalidURI) Error() string

func (*InvalidURI) PyTypeName

func (e *InvalidURI) PyTypeName() string

type OpenTimeoutError

type OpenTimeoutError struct{}

Opening handshake that outlasted the open timeout, the TimeoutError websockets connect raises

func (*OpenTimeoutError) Error

func (e *OpenTimeoutError) Error() string

func (*OpenTimeoutError) PyTypeName

func (e *OpenTimeoutError) PyTypeName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL