pyaiohttpws

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 14 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

Overview

Package pyaiohttpws is a client websocket with the receive, close and heartbeat behaviour of aiohttp

Index

Constants

View Source
const (
	UserAgent      = "Python/3.14 aiohttp/3.14.5"
	Accept         = "*/*"
	AcceptEncoding = "gzip, deflate, zstd"
)

Session default headers of the pinned aiohttp 3.14.5 on Python 3.14 with zstd importable and Brotli absent

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

One open client websocket with its reader, heartbeat and close state

func Connect

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

Opens a client websocket the way a session ws_connect does, the upgrade bounded by the session total timeout

func (*Conn) Close

func (c *Conn) Close(ctx context.Context) bool

Sends the close frame, waits the close timeout for the peer to end the stream and drops the connection

func (*Conn) CloseCode

func (c *Conn) CloseCode() int

Close code of the connection, zero while none is known

func (*Conn) Closed

func (c *Conn) Closed() bool

Whether the websocket is closed as its owner has seen it, by a local close or a received end of stream

func (*Conn) Receive

func (c *Conn) Receive(ctx context.Context) (Message, error)

Next message, the context error when it ends the wait and a closed message after the stream ended

func (*Conn) SendStr

func (c *Conn) SendStr(text string) error

Sends one text frame, the reset error when the websocket is closing or closed

type ConnectionResetError

type ConnectionResetError struct{}

ClientConnectionResetError of a write on a websocket that is closing or closed

func (*ConnectionResetError) Error

func (e *ConnectionResetError) Error() string

func (*ConnectionResetError) PyTypeName

func (e *ConnectionResetError) PyTypeName() string

type ConnectorError

type ConnectorError struct {
	Text string
	Err  error
}

ClientConnectorError of a websocket that could not connect, Err the os_error behind it

func (*ConnectorError) Error

func (e *ConnectorError) Error() string

func (*ConnectorError) PyTypeName

func (e *ConnectorError) PyTypeName() string

func (*ConnectorError) Unwrap

func (e *ConnectorError) Unwrap() error

type HandshakeError

type HandshakeError struct {
	Status int
	URL    string
}

WSServerHandshakeError of an upgrade the server refused

func (*HandshakeError) Error

func (e *HandshakeError) Error() string

func (*HandshakeError) PyTypeName

func (e *HandshakeError) PyTypeName() string

type Message

type Message struct {
	Type  MsgType
	Data  any
	Extra string
}

One received message, Data a string for text, bytes for binary, the close code for close and the error for error

type MessageTooBigError

type MessageTooBigError struct {
	Size  int64
	Limit int64
}

WebSocketError of a received message at or over the max_msg_size limit

func (*MessageTooBigError) Error

func (e *MessageTooBigError) Error() string

func (*MessageTooBigError) PyRepr

func (e *MessageTooBigError) PyRepr() string

func (*MessageTooBigError) PyTypeName

func (e *MessageTooBigError) PyTypeName() string

type MsgType

type MsgType int

Message kind with the numeric values of aiohttp WSMsgType

const (
	Text    MsgType = 0x1
	Binary  MsgType = 0x2
	Close   MsgType = 0x8
	Closing MsgType = 0x100
	Closed  MsgType = 0x101
	Error   MsgType = 0x102
)

func (MsgType) String

func (t MsgType) String() string

Decimal value the way an IntEnum member prints through percent s

type Options

type Options struct {
	// Silence before a ping is sent, its pong due within half of it
	Heartbeat time.Duration
	// Wait for the peer's close frame on close, ten seconds when zero
	CloseTimeout time.Duration
	// Proxy settings read from the environment
	TrustEnv bool
	// Explicit proxy URL that wins over the environment
	Proxy     string
	TLSConfig *tls.Config
	Header    http.Header
	// Text aiohttp prints for the ssl argument in a connect error, default when empty
	SSLLabel string
	// Message size refused as too big at or over this many bytes, zero for no limit
	MaxMsgSize int64
}

Keywords of one ws_connect call

type ServerTimeoutError

type ServerTimeoutError struct{ PongSeconds float64 }

ServerTimeoutError of a heartbeat whose pong never arrived within the pong window

func (*ServerTimeoutError) Error

func (e *ServerTimeoutError) Error() string

func (*ServerTimeoutError) PyTypeName

func (e *ServerTimeoutError) PyTypeName() string

Jump to

Keyboard shortcuts

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