IPWorks MQ 2020 Delphi Edition

Questions / Feedback?

AzureRelayReceiver Component

Properties   Methods   Events   Configuration Settings   Errors  

An Azure Relay Service listener to accept and communicate with clients.

Syntax

TipqAzureRelayReceiver

Remarks

The AzureRelayReceiver component implements the listener role in the Azure Relay service. The component will connect to the server and listen for incoming connections. Once a connection is established data can be exchange freely in both directions allowing a flexible messaging environment.

Authenticating and Listening

Authentication to Azure Relay is performed using the Shared Access Key Name and Shared Access Key created from the Azure portal for the Relay. To begin listening for incoming connections set Listening to True.

When set to True the component will immediately attempt to make a connection to the Azure Relay Service and begin listening. The following properties are applicable when setting Listening:

To stop listening set Listening to False. To shutdown the server including existing connections call Shutdown.

Handling Connections

When a connection is made the ConnectionRequest event fires with information about the connecting client. From within this event the client connection may be accepted (default) or rejected.

If the client connection is accepted the ConnectionConnected and ConnectionReadyToSend events fire when the connection completes and is ready to send and receive data.

When data is received from the client the ConnectionDataIn event fires with the received data.

To send data to the client set DataToSend or call Send, SendFile, or SendText.

When the client disconnects the ConnectionDisconnected event fires. To initiate the client disconnection call Disconnect.

Handling HTTP Connections

Azure Relay also supports HTTP connections which follow a request/response model. When an HTTP request is received the HTTPRequest event fires with information about the request including the request body. Save the ConnectionId value obtained within HTTPRequest for use with SendHTTPResponse.

To send a HTTP response call SendHTTPResponse with the ConnectionId, status code and description, and any response day to be sent back to the client.

Forwarding Connections

The component supports forwarding incoming connection to a separate destination. This functionality allows AzureRelayReceiver to act as a proxy for incoming requests. When ForwardingHost and ForwardingPort are set anytime a connection is made the component will establish a separate connection to the ForwardingHost and forward all incoming traffic. Responses from the ForwardingHost are then automatically sent back over the connection.

When connection forwarding is used no special steps are needed to send or receive data. Data flows freely between the connected client and the ForwardingHost.

Note: Forwarding is not supported for HTTP requests.

Code Example (WebSockets)


Azurerelayreceiver listener = new Azurerelayreceiver();
listener.AccessKey = "9oKRDwjl0s440MlLUi4qHxDL34j1FS6K3t5TRoJ216c=";
listener.AccessKeyName = "RootManageSharedAccessKey";
listener.NamespaceAddress = "myrelay.servicebus.windows.net";
listener.HybridConnection = "hc1";

listener.OnConnectionRequest += (s, e) =>
{
  Console.WriteLine("Connection Request From: " + e.RemoteAddress + ":" + e.RemotePort);
  e.Accept = true;
};

listener.OnConnectionReadyToSend += (s, e) =>
{
  Console.WriteLine("Connection [" + e.ConnectionId + "] connected and ready to send and receive.");
};

listener.OnConnectionDataIn += (s, e) =>
{
  Console.WriteLine("Received data from " + e.ConnectionId + ": " + e.Text);
  //echo the data back
  listener.SendText(e.ConnectionId, e.Text);
  Console.WriteLine("Echoed received data back");
};

listener.Listening = true;

while (true)
  listener.DoEvents();

Code Example (HTTP)


Azurerelaylistener listener = new Azurerelaylistener();
listener.AccessKey = "9oKRDwjl0s440MlLUi4qHxDL34j1FS6K3t5TRoJ216c=";
listener.AccessKeyName = "RootManageSharedAccessKey";
listener.NamespaceAddress = "myrelay.servicebus.windows.net";
listener.HybridConnection = "hc1";

listener.OnHTTPRequest += (s, e) => {
  Console.WriteLine("HTTP Request from " + e.RemoteAddress + ":" + e.RemotePort);
  Console.WriteLine("HTTP Method: " + e.RequestMethod);
  Console.WriteLine("HTTP Request: " + e.RequestData);
  myConnectionId = e.ConnectionId;
};

//Send a response using the ConnectionId value from the HTTPRequest event
listener.SendHTTPResponse(myConnectionId, 200, "OK", myResponseBody);

Property List


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

AccessKeyThe Shared Access Key.
AccessKeyNameThe Shared Access Key Name.
ConnectedShows whether the component is connected.
ConnectionsA collection of currently connected clients.
DefaultTimeoutAn initial timeout value to be used by incoming connections.
FirewallA set of properties related to firewall access.
ForwardingHostThe address to which traffic will automatically be forwarded.
ForwardingPortThe port to which traffic will automatically be forwarded.
HybridConnectionThe hybrid connection name.
ListeningIf True, connects to the Azure Relay Service and listens for incoming connections.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
NamespaceAddressThe namespace address of the relay.
ProxyA set of properties related to proxy access.
SSLAcceptServerCertEncodedThe certificate (PEM/base64 encoded).
SSLCertEncodedThe certificate (PEM/base64 encoded).
SSLCertStoreThe name of the certificate store for the client certificate.
SSLCertStorePasswordIf 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.
SSLCertStoreTypeThe type of certificate store for this certificate.
SSLCertSubjectThe subject of the certificate used for client authentication.
SSLServerCertEncodedThe certificate (PEM/base64 encoded).

Method List


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

ConfigSets or retrieves a configuration setting.
DisconnectDisconnect the specified client.
DoEventsProcesses events from the internal message queue.
InterruptInterrupts a synchronous send to the remote host.
SendSends binary data to the client.
SendFileSend file to the remote host.
SendHTTPResponseSend the HTTP response.
SendTextSends text data to the client.
ShutdownShuts down the server.

Event List


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

ConnectedFired immediately after a connection completes (or fails).
ConnectionConnectedFired when a client has connected.
ConnectionDataInFired when data is received.
ConnectionDisconnectedFired when a WebSocket connection is disconnected.
ConnectionErrorInformation about errors during data delivery.
ConnectionReadyToSendFired when the component is ready to send data.
ConnectionRequestFires when a WebSocket connection is requested.
ConnectionStatusFired to indicate changes in connection state.
DisconnectedFired when a connection is closed.
ErrorInformation about errors during data delivery.
HeaderFired every time a header line comes in.
HTTPRequestFires when an HTTP request is received.
LogFires once for each log message.
RedirectFired when a redirection is received from the server.
SSLServerAuthenticationFired after the server presents its certificate to the client.
SSLStatusShows the progress of the secure connection.

Configuration Settings


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

AccessTokenReturns an access token for use outside of the components.
AutoRenewThresholdThe threshold in seconds after which the token is renewed.
AzureRelayKeepAliveTimeThe inactivity period in seconds before a ping packet is sent to keep the connection alive.
DiagnosticIdA diagnostic id used to enable end-to-end tracing.
LogLevelThe level of detail that is logged.
TokenValidityThe validity time in seconds of the access token.
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 component will forcibly close a connection.
AllowedClientsA comma-separated list of host names or IP addresses that can access the component.
BindExclusivelyWhether or not the component considers a local port reserved for exclusive use.
CloseStreamAfterTransferIf true, the component will close the upload or download stream after the transfer.
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.
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.
UseIPv6Whether to use IPv6.
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.
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 MQ 2020 Delphi Edition - Version 20.0 [Build 8162]