Indy supports ALPN (Application Layer Protocol Negotiation)

ALPN or Application Layer Protocol Name is a TLS extension that includes the protocol negotiation within the exchange of hello messages. ALPN is able to negotiate which protocol should be handled over a secure connection in a way that is more efficient and avoids additional round trips. The ever-growing in popularity HTTP/2 protocol, makes use of ALPN to further decrease website load times and encrypt connections faster.

According to the RFC 7301 specification, with ALPN the client will send a list of supported application protocols to the server as part of the TLS ClientHello message. The server then selects a protocol and sends back that protocol in its ServerHello message. The application protocol negotiation can therefore be accomplished over one single round trip within the TLS handshake. This method also allows the server to associate a different certificate with each application protocol.

From sgcWebSockets 4.3.2, if you compile sgcWebSockets with our custom Indy library you can make use of ALPN protocol. Indy by default doesn't implements this protocol.


Create a new websocket client which requires "h2" for ALPN, check after connects which protocol has server accepted.

oClient := TsgcWebSocketClient.Create(nil);
oClient.Host := '';
oClient.Port := 443;
oClient.TLS := True;
oClient.Active := True;

procedure OnClientConnect(Connection: TsgcWSConnection);
  vProtocol: string;
  vProtocol := TsgcWSConnectionClient(Connection).ALPNProtocol;


 Create a new websocket client which checks if client supports "h2" ALPN connections.

oServer := TsgcWebSocketServer.Create(nil);
oServer.Port := 443;
oServer.SSL := True;
oServer.Active := True;

procedure OnServerSSLALPNSelect(Sender: TObject; aProtocols: TStringList; var aProtocol: string);
  if aProtocols.IndexOf('h2') > -1 then
    aProtocol := 'h2';
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Support for Rad Studio 10.3.3 and Android 64-bit
OpenSSL 1.1 Indy

Related Posts