Skip to main content

Create connection

Creates a WebSocket connection

Function CreateConnection(Val Address, Val Tls = Undefined, Val Proxy = Undefined, Val Headers = Undefined, Val Logging = Undefined) Export

ParameterCLI optionTypeRequiredDescription
Address-StringAddress and port
Tls-Structure Of KeyAndValueTLS settings, if necessary. See GetTlsSettings
Proxy-Structure Of KeyAndValueProxy settings, if required. See GetProxySettings
Headers-Map Of KeyAndValueMap of additional HTTP headers for handshake
Logging-Structure Of KeyAndValueLogging settings. See GetLoggingSettings
Returns

Map Of KeyAndValue, Arbitrary - Client object or map with error information

Caution

NOCLI: this method is not available in CLI version

1C:Enterprise/OneScript code example
Address = "wss://127.0.0.1:8443";
NeedProxy = True;
NeedTLS = True;

Headers = New Map;
Headers.Insert("X-Trace-Id", "OPI-WS-TEST");

If NeedTls Then
TLSSettings = OPI_WebSocket.GetTlsSettings(True);
EndIf;

If NeedProxy Then

ProxyAddress = "127.0.0.1";
ProxyPort = "8071";
ProxyType = "http";

ProxtUser = "proxyuser";
ProxyPassword = "12we...";

ProxySettings = OPI_AddIns.GetProxySettings(ProxyAddress
, ProxyPort
, ProxyType
, ProxtUser
, ProxyPassword);

EndIf;

Result = OPI_WebSocket.CreateConnection(Address, TLSSettings, ProxySettings, Headers);
Result
"AddIn.OPI_WSClient.Main"