I cannot connect to my Node.js WebSocket Server
Hi,
Newbie in Azure here and I am just trying out how to deploy Node.js application in Azure App Services
I am following this link when I am trying to deploy my Node.js WebSocket server in Azure App services.
When I try to run my Node.js with WebSocket server locally then it works with no issues.
But when I try to deploy it in Azure App services then I cannot connect to this
wss://<name>-webapp.azurewebsites.net
The basic quickstart website is available though
I have tried the following already based on what I have been reading on the internet
- Deployed it in B1 or B2 and not on F1 free. I tried the premium as well
- Use Windows instead of Linux during deployment and turn on WebSocket on the configuration option.
I have read somewhere that WebSocket is available even in F1 free services but I am not able to make it work.
Any hints, please?
My app.js taken from the quickstart guide for Node.js https://learn.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=linux&pivots=development-environment-vscode
var createError = require("http-errors");
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
const WebSocket = require("ws");
var indexRouter = require("./routes/index");
var usersRouter = require("./routes/users");
var app = express();
// const port = process.env.PORT || 3000;
const wss = new WebSocket.Server({ server: app });
wss.on("connection", function connection(ws) {
ws.on("message", function incoming(message) {
console.log("received: %s", message);
});
ws.send("something from server");
});