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
xEnableBOOLTRUE: Activates the defined operationFALSE: Aborts/resets the defined operationLCon
Output
xDoneBOOLTRUE: Ready condition reachedLCon
xBusyBOOLTRUE: Operation is runningLCon
xErrorBOOLTRUE: Error condition reachedLCon
Inout
sUriSTRING(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
itfTLSContextNBS.ITLSContext0
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
itfAsyncPropertyNBS.IAsyncProperty0
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)
udiTimeOutUDINT0
Defines the time (µs) after which the connection setup aborts with xError.
sProtocolSTRING‚chat‘
Sec-WebSocket-Protocol The underlaying subprotocols like ‚mqtt‘. Default: ‚chat‘
sExtensionsSTRING‚‘
Sec-WebSocket-Extensions Note: The extension data must be added manually to the payload data. Default: ‚‘, no extension
sAdditionalHttpHeaderSTRING‚‘
Additional http header data Additional http headers must be delimited and closed with $R$N Default: ‚‘
tPingIntervalTIMETIME#0ms
Ping interval, T#0s: no ping
httpProxySettingsSTRUCT(sProxyUser := ‚‘, sProxyPassword := ‚‘, sProxyServer := ‚‘, uiProxyPort := 8080)
Optional http proxy settings
Input Const
udiBufferSizeUDINT2024
The maximum size of the send and receive buffer. Changes during an online change have no effect on the buffer size.
Output
xActiveBOOLTRUE if a connection is established
eErrorError state
sSupportedProtocolsSTRINGSupported protocols (server side)
sSupportedExtensionsSTRINGSupported extensions (server side)
Methods:
Structure: