dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.22k stars 9.95k forks source link

Blazor server side not close WebSocket on iframe destroy. #49487

Open Planit-Scheduler-Solutions opened 1 year ago

Planit-Scheduler-Solutions commented 1 year ago

Is there an existing issue for this?

Describe the bug

Hi, I work with blazor server side(.net 6) for show small applications in my main application. In my main applications (implement by angular) I open some popups that includes iframe that show the blazor apps. After some work I found that the blazor on each load open a websocket but after I destroy the iframe this websockets never close(close only if I refresh the main application tab). 2

How can I stop the old WebSocket?

Expected Behavior

In my main application can be display only one blazor view in the same time, so I expect to see only one websocket in the network in the same time.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6

Anything else?

No response

mkArtakMSFT commented 1 year ago

Thanks for contacting us. Do you observe this behavior with different browsers or with a specific one? Can you try this out with Firefox , Google Chrome and Microsoft Edge and see if you notice any differences?

ghost commented 1 year ago

Hi @Planit-Scheduler-Solutions. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Planit-Scheduler-Solutions commented 1 year ago

Thanks for the quick response. After some checks on "Google Chrome, Microsoft Edge" I found that the problem of not closed WebSocket is only if my main application is in the debug mode(not production), if I in production mode the WebSocket closed.

After check of the Firefox I am not sure but it looks like the WebSocket closed in production mode and also in debug mode.

Firefox (production mode): image

Firefox (debug mode): image

mkArtakMSFT commented 1 year ago

Thanks for the additional details. What is the debug / production modes that you're referring to? Are these some browser modes or are you trying to start your app in such mode and that results in the behavior change ?

Planit-Scheduler-Solutions commented 1 year ago

When running "ng serve" in an angular environment, it's by default uses the "debug" configuration. That's when the bug appears.

When building it to production, it uses the "release" configuration in the angular environment - and in this configuration the issue does not occur.

No special browser modes involved in here.

javiercn commented 1 year ago

@Planit-Scheduler-Solutions thanks for contacting us.

This is likely something regarding the proxy configuration for angular. You can probably look at how to configure it here