Websocket for Blazor doesn't work with Openlitespeed on Centos

blinkor12 101 Reputation points
2022-04-05T01:27:04.863+00:00

I have Openlitespeed installed on my CentOS server.

I deployed a Blazor app to the server after installing dotnet core. The Blazor code runs fine but I cannot get the Websocket to work.
If I look in console, I see that the Blazor application loads but the WebSocket cannot connect with no further error details.

I created this Blazor app by starting the blazor application on port 5000 and created an external app in OpenLiteSpeed as a web server. I then created a virtual host in OLS for my Blazor application.

If I go to the Virtual Host for my website, I can visit the website fine. However, if I look in console, I get an error that Blazor cannot establish a websocket connection to my domain. I tried adding port 80 to the 'Websockets' section of OLS but that made the website unable to load. I then added port 5000 to the websockets section but that didn't resolve the issue either and I received the same error.

If I run the application with Visual Studio on my local computer, the websocket connects fine. However, if I deploy the app to my remove CentOS server, it does not connect properly. My startup script for CentOS looks like this (assume I changed mywebsite.com):

[Unit]
Description=ASP.NET Blazor App

[Service]
WorkingDirectory=/home/mywebsite.com/public_html
ExecStart=/usr/bin/dotnet /home/mywebsite.com/public_html/testapp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

How do I fix this?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,500 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 61,731 Reputation points
    2022-04-05T14:25:42.263+00:00
    0 comments No comments