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 |
[!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:
- Create a Relay namespace by using the Azure portal.
- Create a hybrid connection in that namespace by using the Azure portal.
- Write a server (listener) console application to receive messages.
- Write a client (sender) console application to send messages.
- Run applications.
- Node.js.
- An Azure subscription. If you don't have one, create a free account before you begin.
[!INCLUDE relay-create-namespace-portal]
[!INCLUDE relay-create-hybrid-connection-portal]
To listen and receive messages from the Relay, write a Node.js console application.
[!INCLUDE relay-hybrid-connections-node-get-started-server]
To send messages to the Relay, write a Node.js console application.
[!INCLUDE relay-hybrid-connections-node-get-started-client]
-
Run the server application: from a Node.js command prompt type
node listener.js
. -
Run the client application: from a Node.js command prompt type
node sender.js
, and enter some text. -
Ensure that the server application console outputs the text that was entered in the client application.
Congratulations, you have created an end-to-end Hybrid Connections application using Node.js!
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.