Websocket not working with Azure webapp

  • Thread starter Thread starter phk101
  • Start date Start date
P

phk101

Guest
Hello,

I'am working on websocket app. I have used Fleck(C# library) for websocket server. This demo is working in my localhost but when i deploy it to Azure webapp it give error

System.Net.Sockets.SocketException (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at Fleck.SocketWrapper.Bind(EndPoint endPoint) at Fleck.WebSocketServer.Start(Action`1 config) at FleckDemo2.FleckSocket.Start()

Below is the code snippet to start websocket:


string ipAddress = string.Empty;
var host = System.Net.Dns.GetHostEntry(Dns.GetHostName());

List<IWebSocketConnection> sockets = new List<IWebSocketConnection>();

foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
ipAddress = ip.ToString();
break;
}
}
Fleck.WebSocketServer server = new Fleck.WebSocketServer("ws://" + ipAddress + ":80");


server.Start(socket =>
{
logger.Info("FleckSocket=>server.start");
socket.OnOpen = () =>
{
logger.Info("FleckSocket=>server.open");
sockets.Add(socket);
};
socket.OnClose = () =>
{
logger.Info("FleckSocket=>server.close");
sockets.Remove(socket);
};
socket.OnMessage = message =>
{
logger.Info("FleckSocket=>server.message and the message is : "+message);
sockets.ToList().ForEach(s => s.Send(" client says: " + message));
};

});


I have also enabled "websocket-> on" under general settings of web application.

Thank You


Continue reading...
 
Back
Top