Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWA CLI Fails to Start the Application #42

Closed
onerdy opened this issue Mar 15, 2023 · 6 comments
Closed

SWA CLI Fails to Start the Application #42

onerdy opened this issue Mar 15, 2023 · 6 comments

Comments

@onerdy
Copy link

onerdy commented Mar 15, 2023

I followed the ReadMe directions for Visual Studio Code. Installed the latest VS Code v1.76.1 on Windows 11. Installed Azure Static Web Apps CLI and Azure Functions Core Tools CLI per the ReadMe file. Deleted the appsettings.Development.json file per the ReadMe.

When running the command "swa start http://localhost:5000 --api-location http://localhost:7071" , it attempts to start the application and eventually times out with this output:

[swa] - Waiting for http://localhost:5000 to be ready
[swa] ✖Waiting for http://localhost:5000 to be ready
[swa] ✖ Could not connect to "http://localhost:5000". Is the server up and running?
[swa] node "C:\Users\myusername\AppData\Roaming\npm\node_modules@azure\static-web-apps-cli\dist\msha\server.js" exited with code 0

Any ideas how to make this work?

Edit: I also tried to run and debug the Client/Server option and receive error "Unable to launch browser: "Could not open ...:5001/_framework/debug/ws-proxy?browser=ws%3A%2F%2F127.0.0.1%3A4477%2Fdevtoo..."

Edit2: Using the option to run and debug Client/Server is successfully launching the Azure Function Host but the error is happening after that when it tries to launch the wasm app in browser. If I wait for the Function Host to successfully start and ignore the launch error I can manually browse to http://localhost:5000 and the app is working properly. So perhaps if I just resolve the launch issue that will be sufficient.

@onerdy
Copy link
Author

onerdy commented Mar 15, 2023

I believe I have resolved this issue by adding a url property in the launch.json file. (Edit: I had to restart VS Code after modifying this launch.json file).

Now, when I run and debug Client/Server everything works.

I'm not sure if this is worth considering adding to the default repo or if that might be inappropriate for other environments.
Or perhaps at least updating the ReadMe file with this information. Also, perhaps clarify in the ReadMe file if/when it is appropriate to run "swa start http://localhost:5000/ --api-location http://localhost:7071/" because that did not work for me at all and it caused confusion.

The final launch.json looks like this:

{
  "version": "0.2.0",
  "configurations": [

    {
      "name": "Launch and Debug Standalone Blazor WebAssembly App",
      "type": "blazorwasm",
      "request": "launch",
      "cwd": "${workspaceFolder}/Client",
      "url": "http://localhost:5000"
    },
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:azureFunctions.pickProcess}"
    }
  ],
  "compounds": [
    {
      "name": "Client/Server",
      "configurations": [
        "Attach to .NET Functions",
        "Launch and Debug Standalone Blazor WebAssembly App"
      ]
    }
  ]
}

@oneolddev
Copy link
Contributor

@onerdy

I think you may have run across multiple issues.

  1. Adding "url": "http://localhost:5000" to launch.json is necessary for VSCode to attach the debugger. Without it, VSCode attempts to attach using the default https://localhost:5001. An alternative is to alter launchSetting.json by changing applicationUrl to "https://localhost:5001;http://localhost:5000".
  2. Node 18 issues with SWA CLI - [start] Start command does not connect to web or api server on Node 18 Azure/static-web-apps-cli#663. There is no issue with Node 16. See that issue for more information.

I hope this is helpful.

@onerdy
Copy link
Author

onerdy commented Mar 20, 2023

@c0g1t8

Hi Gary, thanks a lot for taking the time to reply!

@oneolddev
Copy link
Contributor

@onerdy

You should close this issue if ti's resolved. 😄.

@onerdy
Copy link
Author

onerdy commented Mar 25, 2023

@onerdy

You should close this issue if ti's resolved. 😄.

Oops, sorry! I thought I closed after last comment. I'll close it now.

@onerdy onerdy closed this as completed Mar 25, 2023
@jacksorjacksor
Copy link

While I'll post on Azure/static-web-apps-cli#663 I just wanted to say that I'm also having the [swa] ✖ Could not connect to "http://localhost:5000/". Is the server up and running? issues. From that discussion it looks like Node 18 is now compatible with local SWA usage, but that's not been the case for me.

I'm definitely struggling to use Blazor WASM + CosmosDB (local) through a local static web app. The only tutorial I can find for using Blazor+CosmosDB+SWA is Aaron Powell's blog post - sadly his accompanying repo, run in a dev container, results in a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants