Created project by Micosoft Visual Studio "ASP.NET with React+Redux" template. In that case app running by IIS Express. But hot-reload for react-app doesn't work and shows error in console: "WebSocket connection to 'wss://localhost:54691/ws' failed:"
After some research, I found a solution: disable SSL in IIS settings. But how can I achieve using hot reload when SSL is enabled?
package.json dependencies:
"dependencies": {
"#emotion/react": "^11.8.2",
"#emotion/styled": "^11.8.1",
"#mui/material": "^5.5.2",
"#reduxjs/toolkit": "^1.8.1",
"history": "4.10.1",
"node-sass": "^6.0.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-scripts": "5.0.0",
"react-redux": "~7.2.6",
"react-router-dom": "6.2.1",
"redux": "4.1.2",
"redux-thunk": "2.4.1",
"typescript": "4.4.4"
},
launchSettings.json generated by template (SSL enabled)
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:48763",
"sslPort": 44373
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyProject": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
error message:
WebSocketClient.js:16 WebSocket connection to 'wss://localhost:54691/ws' failed:
WebSocketClient # WebSocketClient.js:16
initSocket # socket.js:24
./node_modules/webpack-dev-server/client/index.js?protocol=ws%3A&hostname=0.0.0.0&port=54691&pathname=%2Fws&logging=none&reconnect=10 # index.js:273
options.factory # react refresh:6
__webpack_require__
Related
Hello I want to apply Hsts (Strict-Transport-Security) and I want to implement and test in my local.
But i can't change my application Url from http to https version . I tried solutions on other answers but did not worked. I tried 443 port / I tried delete .vs config file but it does not exist.
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:47000",// This was working http
"sslPort": 0
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger/index.html",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Product.Core.WebApi": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000"
}
}
}
I use Visual Studio Enterprise 2022 (64-bit) version 17.4, .Net 7, and BlazorWebAssembly.
When I use BlazorWebAssembly and try to debug a Blazor client-side app, I keep getting the error
Debugging connection was closed. Reason : WebSocket disconnected
This is my code launchSettings.json
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:33139",
"sslPort": 0
}
},
"profiles": {
"BlazorApp": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5149",
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
},
"WSL": {
"commandName": "WSL2",
"launchBrowser": true,
"launchUrl": "http://localhost:5149",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5149"
},
"distributionName": ""
}
}
}
I try this Debug ASP.NET Core Blazor WebAssembly
but it doesn't work.
Add app.UseBlazorDebugging(); inside the if (env.IsDevelopment()) block in Startup.cs will resolved your issue.
When debugging in VS 2019 the api url automatically opens which is different from the angular live url.
The angular live url is my actual complete application. Is there a way to open that url automatically when debugging?
I think you need to modify your json config a little bit. So when you use VS to run your code or using dotnet run command you will use port 59709 to run your app
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59709/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"ancmHostingModel": "InProcess"
},
"KaddaTechnologies": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:59709/"
}
}
}
Project (full net461, core 1.1) converted from VS2015:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17901/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApplication1": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Also no browsers opens automatically after F5. (But site opens when I go to url manually).
And I also cannot create not Core web project in 2017 to see how it works - VS just writes something about "failed to create project" in bottom line and empty solution explorer, only folder created, nothing in Output, nothing in devenv /Log C:/log.xml log.
To fix: enable "Azure App service Tools"
My launchSettings.json is (after changing launchUrl to applicationUrl):
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5000/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5050/"
},
"Project Development": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "http://localhost:5050/"
}
}
}
Previously both profiles opened http://localhost:5050/. Now second profile just starts the server and first shows "The project doesn't know how to run the profile IIS Express" error.