IPWorks WebSockets 2020 Python Edition

Questions / Feedback?

WebSocketServer Class

Properties   Methods   Events   Configuration Settings   Errors  

The WebSocketServer class is used to create a WebSocket server.

Syntax

class ipworksws.WebSocketServer

Remarks

The WebSocketServer class provides an easy way to accept connections from WebSocket clients and transfer data.

The WebSocketServer class is a server that accepts incoming WebSocket connections and provides an easy way to send and receive data over the connection.

To begin using the class first specify a valid value for local_port. This is the port on which incoming connections will be accepted. To begin listening set listening to True.

When a client connects the on_web_socket_open_request event will fire. To accept the connection simply allow the event to complete. To reject the request set the StatusCode parameter to an HTTP error code (such as 401).

Once the connection is received incoming data will be provide through the on_data_in event. To send data to a client you may use the send, send_text, or send_file methods. You may also set web_socket_connection_data_to_send.

Note: Server components are designed to process events as they occur. To ensure events are processed in a timely manner do_events should be called in a loop after the server is started.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

connection_backlogThe maximum number of pending connections maintained by the TCP/IP subsystem.
web_socket_connection_countThe number of records in the WebSocketConnection arrays.
web_socket_connection_accept_dataSetting this property to False, temporarily disables data reception (and the DataIn event) on the connection.
web_socket_connection_bytes_sentThis property shows how many bytes were sent after the last assignment to DataToSend .
web_socket_connection_connectedThis property is used to disconnect individual connections and/or show their status.
web_socket_connection_connection_idThis property contains an identifier generated by the class to identify each connection.
web_socket_connection_data_formatThe format of the data being sent.
web_socket_connection_data_to_sendThis property contains a string of data to be sent to the remote host.
web_socket_connection_hostThe Host header value of the connected client.
web_socket_connection_local_addressThis property shows the IP address of the interface through which the connection is passing.
web_socket_connection_originThe Origin header value of the connected client.
web_socket_connection_ready_to_sendIndicates whether the class is ready to send data.
web_socket_connection_remote_hostThis property shows the IP address of the connected client.
web_socket_connection_remote_portThis property shows the port of the connected client.
web_socket_connection_request_headersThe HTTP headers sent by the client in the initial WebSocket connection request.
web_socket_connection_request_uriThe requested URI sent by the client in the initial WebSocket connection request.
web_socket_connection_sub_protocolsThe subprotocols (application-level protocols layered over the WebSocket Protocol) sent by the client in the initial WebSocket connection request.
web_socket_connection_timeoutThis property specifies a timeout for the class.
default_timeoutAn initial timeout value to be used by incoming connections.
listeningIf True, the class accepts incoming connections on LocalPort.
local_hostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
local_portThe TCP port in the local host where the class listens.
ssl_authenticate_clientsIf true, the server asks the client(s) for a certificate.
ssl_cert_encodedThe certificate (PEM/base64 encoded).
ssl_cert_storeThe name of the certificate store for the client certificate.
ssl_cert_store_passwordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
ssl_cert_store_typeThe type of certificate store for this certificate.
ssl_cert_subjectThe subject of the certificate used for client authentication.
use_sslDetermines if SSL is negotiated with incoming connections.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

configSets or retrieves a configuration setting.
disconnectDisconnect the specified client.
do_eventsProcesses events from the internal message queue.
interruptInterrupts a synchronous send to the remote host.
sendSends binary data to the client.
send_fileSend file to the remote host.
send_textSends text data to the client.
shutdownShuts down the server.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_connectedFired when a WebSocket is successfully opened.
on_connection_requestFired when a request for connection comes from a remote host.
on_data_inFired when data is received.
on_disconnectedFired when a WebSocket connection is disconnected.
on_errorInformation about errors during data delivery.
on_logFires once for each log message.
on_ready_to_sendFired when the class is ready to send data.
on_ssl_client_authenticationFired when the client presents its credentials to the server.
on_ssl_connection_requestFires when an SSL connection is requested.
on_ssl_statusShows the progress of the secure connection.
on_web_socket_open_requestFired when a client attempts to open a WebSocket.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

BufferMessageIndicates whether or not the entire message is buffered before firing the DataIn event.
DisconnectStatusCodeSpecifies the status code when closing a connection.
DisconnectStatusDescriptionSpecifies the message associated with the disconnect status code.
MaxFrameSizeSpecifies the maximum size of the outgoing message in bytes before fragmentation occurs.
MessageLength[ConnectionId]The length of the message (in bytes) when sending asynchronously.
WaitForCloseResponseDetermines whether or not the class will forcibly close a connection.
AllowedClientsA comma-separated list of host names or IP addresses that can access the class.
BindExclusivelyWhether or not the class considers a local port reserved for exclusive use.
ConnectionUIDThe unique connectionId for a connection.
DefaultConnectionTimeoutThe inactivity timeout applied to the SSL handshake.
InBufferSizeThe size in bytes of the incoming queue of the socket.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveRetryCountThe number of keep-alive packets to be sent before the remotehost is considered disconnected.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
MaxConnectionsThe maximum number of connections available.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.
TcpNoDelayWhether or not to delay when sending packets.
UseIOCPWhether to use the completion port I/O model.
UseIPv6Whether to use IPv6.
UseWindowsMessagesWhether to use the WSAAsyncSelect I/O model.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCACertFilePathsThe paths to CA certificate files on Unix/Linux.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLCheckCRLWhether to check the Certificate Revocation List for the server certificate.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLEnableRenegotiationWhether the renegotiation_info SSL extension is supported.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLNegotiatedCipherReturns the negotiated ciphersuite.
SSLNegotiatedCipherStrengthReturns the negotiated ciphersuite strength.
SSLNegotiatedCipherSuiteReturns the negotiated ciphersuite.
SSLNegotiatedKeyExchangeReturns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrengthReturns the negotiated key exchange algorithm strength.
SSLNegotiatedProtocolReturns the negotiated protocol version.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLServerCACertsA newline separated list of CA certificate to use during SSL server certificate validation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks WebSockets 2020 Python Edition - Version 20.0 [Build 8155]