WebSocketClient (FB)¶
FUNCTION_BLOCK WebSocketClient EXTENDS CBML.LCon IMPLEMENTS IWebSocketClient
Function block to establish a connetion to a WebSocket server.
- InOut:
Scope
Name
Type
Initial
Comment
Inherited from
Input
xEnable
BOOL
TRUE
: Activates the defined operationFALSE
: Aborts/resets the defined operationLCon
Output
xDone
BOOL
TRUE
: Ready condition reachedLCon
xBusy
BOOL
TRUE
: Operation is runningLCon
xError
BOOL
TRUE
: Error condition reachedLCon
Inout
sUri
STRING(1024)
The uri of the server. e.g ‚ws://localhost:8080‘ ws-URI = „ws:“ „//“ host [ „:“ port ] path [ „?“ query ] wss-URI = „wss:“ „//“ host [ „:“ port ] path [ „?“ query ]
Input
itfTLSContext
NBS.ITLSContext
0
User defined TLS context for encrypted TCP connections (only for wss-URIs). If the TLS context is 0 then a default TLS context will be created for wss-URIs.
Usage: Static initialization, as shown in the following code snippet.
VAR commonName : STRING := 'MyRrasPi'; ciCertInfo : NBS.CERT_INFO := (psInfo:=ADR(commonName), udiSize:=LEN(commonName)); myTLSContext : NBS.TLSContext := ( ePurpose:=NBS.PURPOSE.CLIENT_SIDE, sUseCaseName:='NBSTest', sTLSVersion:='1.3', ciCertInfo:=ciCertInfo, udiVerificationMode:=2 ); END_VAR
itfAsyncProperty
NBS.IAsyncProperty
0
Runs the connect process in a own background task. Use this property if the connection setup takes longer than one task cycle (e.g. TLS connections)
udiTimeOut
UDINT
0
Defines the time (µs) after which the connection setup aborts with xError.
sProtocol
STRING
‚chat‘
Sec-WebSocket-Protocol The underlaying subprotocols like ‚mqtt‘. Default: ‚chat‘
sExtensions
STRING
‚‘
Sec-WebSocket-Extensions Note: The extension data must be added manually to the payload data. Default: ‚‘, no extension
sAdditionalHttpHeader
STRING
‚‘
Additional http header data Additional http headers must be delimited and closed with $R$N Default: ‚‘
tPingInterval
TIME
TIME#0ms
Ping interval, T#0s: no ping
httpProxySettings
STRUCT(sProxyUser := ‚‘, sProxyPassword := ‚‘, sProxyServer := ‚‘, uiProxyPort := 8080)
Optional http proxy settings
Input Const
udiBufferSize
UDINT
2024
The maximum size of the send and receive buffer. Changes during an online change have no effect on the buffer size.
Output
xActive
BOOL
TRUE if a connection is established
eError
Error state
sSupportedProtocols
STRING
Supported protocols (server side)
sSupportedExtensions
STRING
Supported extensions (server side)
Methods:
Structure: