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

Blazor Server-Side Websocket closed with status code '1006' on real hosting #21546

Closed
Domivan opened this issue May 6, 2020 · 14 comments
Closed
Labels
area-signalr Includes: SignalR clients and servers Blazor ♥ SignalR This issue is related to the experience of Signal R and Blazor working together investigate
Milestone

Comments

@Domivan
Copy link

Domivan commented May 6, 2020

Good day!
Problem with server-side blazor.
On the real hosting, the application constantly loses connection with the server, reporting an error "websocket closed with status code 1006".
Already broke his head in search of a cause.
At the same time, the application works without problems on the local computer in development mode.
It got to the point that I decided to simulate everything from scratch.
It turned out that any blazor application loses its connection in the conditions of limitations of the iis server dedicated vitrual memory.
I created the start-up template of the blazor-server side application, didn’t add anything, published it on the local iis, in the iis settings I set 20Gb for virtual memory and 2Gb for allocated memory and I get websocket disconnections when the Click button on the Count page is clicked actively.
If you set the virtual memory size to 0, no shutdowns occur. But this does not meet the conditions of real hosting.
Friends, what's the problem?

@javiercn javiercn added the area-blazor Includes: Blazor, Razor Components label May 7, 2020
@Domivan
Copy link
Author

Domivan commented May 7, 2020

Conducted some research:
It seems that in the blazor sources there is a conflict of using a 32-bit library.
When IIS set to "allow to use 32-bit applications" to "true",
websockets are not disconnected

@javiercn
Copy link
Member

javiercn commented May 7, 2020

@Domivan thanks for contacting us and thanks for the details!

We'll look into this issue and update it appropriately. Looping some SignalR folks and Server folks since they will know more.

@BrennanConroy @Tratcher @jkotalik do you have any thoughts on what can be at play here?

@mkArtakMSFT mkArtakMSFT added Blazor ♥ SignalR This issue is related to the experience of Signal R and Blazor working together investigate labels May 7, 2020
@mkArtakMSFT mkArtakMSFT added this to the Next sprint planning milestone May 7, 2020
@BrennanConroy
Copy link
Member

2Gb for allocated memory and I get websocket disconnections

What is the memory usage of your process when the websocket is disconnected? If you're hitting the 2Gb limit then IIS will restart the app and you'll lose all connections.

@Domivan
Copy link
Author

Domivan commented May 7, 2020

Even the usual weather forecast blazor application template loses connection. I create a new application from the blazor server-side template, add nothing, publish it on IIS with a virtual memory limit (1gb) , run app, do nothing and the socket will disconnect in a minute or two. The process does not consume more than 16mb
settings

@mkArtakMSFT mkArtakMSFT removed this from the Next sprint planning milestone May 14, 2020
@mkArtakMSFT
Copy link
Member

Cleared the milestone so this doesn't slip through cracks.

@mkArtakMSFT mkArtakMSFT added area-signalr Includes: SignalR clients and servers and removed area-blazor Includes: Blazor, Razor Components labels May 18, 2020
@BrennanConroy
Copy link
Member

Why are you configuring your Virtual Memory limit? By default it should be 0.

As you observed switching to 32 bit "fixes" the issue. This is likely because 64 bit is more aggressive with using virtual memory.

Also, you could try disabling server GC to see if less virtual memory is used.

@BrennanConroy BrennanConroy added this to the Discussions milestone May 18, 2020
@Domivan
Copy link
Author

Domivan commented May 23, 2020

The virtual memory limit is strictly limited by the hosting provider; I cannot change this limit.

@Domivan
Copy link
Author

Domivan commented Jun 7, 2020

Please share a solution to the problem. I found that all blazor server side applications somehow lose connection with error 1006, even the usual empty weather forecast template hosted on the IIS server. The time of occurrence of the error is not predictable. Reload the page after losing the connection is not a problem, but what about authorization? When disconnected, all authorization data is lost, you have to log in again.
If I’m wrong, provide a link to any blazor server side page that has no websocket disconnection

@BrennanConroy
Copy link
Member

Also, you could try disabling server GC to see if less virtual memory is used.

I mentioned one option, have you tried this out?

You can also try specifying the GC heap limit to keep memory down: https://github.com/dotnet/docs/blob/ed5a85b61908468f050220d8956a6769192f631f/docs/core/run-time-config/garbage-collector.md#systemgcheaphardlimitcomplus_gcheaphardlimit

@WayneHiller
Copy link

Anything new on this? I am having the same issue running the site in Kestrel.

@BrennanConroy
Copy link
Member

If you're using Kestrel stand-alone then open a new issue. Otherwise the conversation above should solve the issue. Unless you have a different problem, in which case also open a new issue.

@mrlife
Copy link
Contributor

mrlife commented Oct 27, 2020

@BrennanConroy I am having this issue on Windows with Apache. The connection is disconnected every few minutes and then reconnects. Sometimes, it has trouble reconnecting, and the app breaks. See the bolded "Error" below.

This is what the console looks like when the app is left idle:

[Info] [2020-10-27T19:35:07.081Z] Information: Normalizing '_blazor' to 'https://MyURL/_blazor'. (blazor.server.js, line 1)
[Info] [2020-10-27T19:35:07.356Z] Information: WebSocket connected to wss://MyURL/_blazor?id=eXbNRQgEV0ypITcjFBbx8w. (blazor.server.js, line 1)
[Info] [2020-10-27T19:36:53.863Z] Information: Connection disconnected. (blazor.server.js, line 1)
[Info] [2020-10-27T19:36:56.871Z] Information: Normalizing '_blazor' to 'https://MyURL/_blazor'. (blazor.server.js, line 1)
[Info] [2020-10-27T19:36:57.167Z] Information: WebSocket connected to wss://MyURL/_blazor?id=OhoM5IM0eTBighz6OLpY3Q. (blazor.server.js, line 1)
[Error] WebSocket network error: The operation couldn’t be completed. Socket is not connected (x2)
[Error] [2020-10-27T19:37:35.404Z] Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 ().'.
(anonymous function) (blazor.server.js:1:5500)
(anonymous function) (blazor.server.js:1:60705)
(anonymous function) (blazor.server.js:1:47567)
(anonymous function) (blazor.server.js:1:46604)

[Info] [2020-10-27T19:37:38.405Z] Information: Normalizing '_blazor' to 'https://MyURL/_blazor'. (blazor.server.js, line 1)
[Info] [2020-10-27T19:37:38.696Z] Information: WebSocket connected to wss://MyURL/_blazor?id=OwqXfjS_pMdEpnLEqsdOQA. (blazor.server.js, line 1)
[Info] [2020-10-27T19:39:46.927Z] Information: Connection disconnected. (blazor.server.js, line 1)
[Info] [2020-10-27T19:39:49.930Z] Information: Normalizing '_blazor' to 'https://MyURL/_blazor'. (blazor.server.js, line 1)
[Info] [2020-10-27T19:39:50.258Z] Information: WebSocket connected to wss://MyURL/_blazor?id=YSG3JJDknVcRwl9crCxdWg. (blazor.server.js, line 1)

@ghost
Copy link

ghost commented Dec 26, 2020

Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!

@ghost ghost closed this as completed Dec 26, 2020
@mrlife
Copy link
Contributor

mrlife commented Dec 26, 2020

@mkArtakMSFT I’m not sure it makes sense for this to be closed.

@dotnet dotnet locked as resolved and limited conversation to collaborators Jan 25, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-signalr Includes: SignalR clients and servers Blazor ♥ SignalR This issue is related to the experience of Signal R and Blazor working together investigate
Projects
None yet
Development

No branches or pull requests

6 participants