question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Server remoting using XHR instead of Websockets

See original GitHub issue

Correct me if I’m wrong, but I was under the impression that Bolero’s server used websockets for real-time server remoting. But when I ran the dev server using dotnet run -p ./src/Baseline.Server on the template app (specifically https://github.com/srid/Baseline), and checked the Chrome inspector, the getBooks call is making a new HTTP request, instead using any websocket connection (there is none).

image

How should I expect it to behave? Are there documentation on this? Can we make the Bolero app using Websocket? What’s the relation to SignalR if any? (I’m new to .NET).

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
sdehmcommented, Sep 13, 2021

You can run SignalR on the client in WebAssembly mode (blazor docs). My app is hosted with ASP.NET but it might work with other hosting models as well. I ended up dropping the remote services and replacing server-client communication with a SignalR connection hooked into Elmish subscriptions to trigger updates as recommended in this issue. It would be cool if you could setup remoting with a SignalR connection like this out of the box but I haven’t looked into the remoting implementation and it might not be trivial to provide that option.

One disadvantage of the Blazor Server (server=true) approach is that any UI event needs to go over the network along with the resulting html diff. In WebAssembly mode you can do a lot of logic on the client and only send what you need to the server, such as persistence data. There are other considerations nicely outlined here.

1reaction
sridcommented, Mar 23, 2021

Ah, my first question is out of misunderstanding I guess. The render mode is in the context of the server serving a path request, where it makes the decision to just dump the HTML (statically) or have the client build it, or prerender it and hydrate it on client. https://stackoverflow.com/a/58231378/55246

Still not sure why a statically generated response won’t be able to use websockets in the client; Oh maybe something to do with SignalR?

In any case, I’d rather have prerendering enabled anyway, and don’t need the performance of full static rendering. So server=true works for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the difference between Websockets and XHR?
Websockets is the persistent connection that can be used to receive/send data without sequential order and without http header. Xhr-polling creates new request ......
Read more >
WebSockets vs XHR for data transfer - javascript
My client is insisting that we should use websockets for data transfer instead of XHR. Just to be clear, we don't need bi-directional ......
Read more >
WebRTC vs WebSockets
Because WebSockets are built-for-purpose and not the alternative XHR/SSE hacks, WebSockets perform better both in terms of speed and resources ...
Read more >
Using SSE Instead Of WebSockets For Unidirectional Data ...
The browser connects to a remote HTTP server and requests the resource specified by the author in the EventSource constructor. The server sends ......
Read more >
Fast Polling vs. Websockets
For short polling, you fire off an XHR request and the server immediately responds. It is a form of Remote Procedure Call (RPC)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found