Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 3.13 KB

relay-hybrid-connections-node-get-started.md

File metadata and controls

60 lines (39 loc) · 3.13 KB
title description ms.topic ms.date ms.custom
Azure Relay Hybrid Connections - WebSockets in Node
Write a Node.js console application for Azure Relay Hybrid Connections WebSockets.
tutorial
01/04/2024
devx-track-js, mode-ui, mode-api

Get started with Relay Hybrid Connections WebSockets in Node.js

[!INCLUDE relay-selector-hybrid-connections]

In this quickstart, you create Node.js sender and receiver applications that send and receive messages by using Hybrid Connections WebSockets in Azure Relay. To learn about Azure Relay in general, see Azure Relay.

In this quickstart, you take the following steps:

  1. Create a Relay namespace by using the Azure portal.
  2. Create a hybrid connection in that namespace by using the Azure portal.
  3. Write a server (listener) console application to receive messages.
  4. Write a client (sender) console application to send messages.
  5. Run applications.

Prerequisites

Create a namespace

[!INCLUDE relay-create-namespace-portal]

Create a hybrid connection

[!INCLUDE relay-create-hybrid-connection-portal]

Create a server application (listener)

To listen and receive messages from the Relay, write a Node.js console application.

[!INCLUDE relay-hybrid-connections-node-get-started-server]

Create a client application (sender)

To send messages to the Relay, write a Node.js console application.

[!INCLUDE relay-hybrid-connections-node-get-started-client]

Run the applications

  1. Run the server application: from a Node.js command prompt type node listener.js.

  2. Run the client application: from a Node.js command prompt type node sender.js, and enter some text.

  3. Ensure that the server application console outputs the text that was entered in the client application.

    Console windows testing both the server and client applications.

Congratulations, you have created an end-to-end Hybrid Connections application using Node.js!

Next steps

In this quickstart, you created Node.js client and server applications that used WebSockets to send and receive messages. The Hybrid Connections feature of Azure Relay also supports using HTTP to send and receive messages. To learn how to use HTTP with Azure Relay Hybrid Connections, see the Node.js HTTP quickstart.

In this quickstart, you used Node.js to create client and server applications. To learn how to write client and server applications using .NET Framework, see the .NET WebSockets quickstart or the .NET HTTP quickstart.