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

Use endpoint routing for remoting #289

Closed
Tarmil opened this issue Feb 22, 2023 · 5 comments
Closed

Use endpoint routing for remoting #289

Tarmil opened this issue Feb 22, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@Tarmil
Copy link
Member

Tarmil commented Feb 22, 2023

Remoting currently uses a middleware, and it should be more performant using endpoint routing.

@Tarmil Tarmil added the enhancement New feature or request label Feb 22, 2023
@granicz
Copy link
Member

granicz commented Feb 22, 2023

We have been discussing this for WebSharper for a while, makes perfect sense. Have you thought of a way to include server-push remoting (using websockets)?

@Tarmil
Copy link
Member Author

Tarmil commented Feb 25, 2023

@granicz A small wrapper for the SignalR client and server libraries would probably be the way to go for this (HotReload already uses them, for example), but I haven't looked into it recently.

Tarmil added a commit that referenced this issue Mar 17, 2023
@fwaris
Copy link

fwaris commented Mar 17, 2023

I have started to use bolero now. However, I am finding that server-based push is a key need for me. I am using bolero to build live dashboards and monitoring systems.

I have signalR working with the following wasm-side snippet to create the connection:

open Microsoft.AspNetCore.SignalR.Client
...
let subscription (loggerProvider: ILoggerProvider) (navMgr:NavigationManager) (dispatch: _ -> unit) =
    let hubConnection =
        HubConnectionBuilder()               
            .AddJsonProtocol(fun o -> SerializationOptions.configureSerialization o.PayloadSerializerOptions)//.Converters.Add (JsonFSharpConverter()))
            .WithUrl(navMgr.ToAbsoluteUri("/chartdata"))
            .WithAutomaticReconnect()           
            .ConfigureLogging(fun logging ->
                logging.AddProvider(loggerProvider) |> ignore
            )           
            .Build()

    hubConnection.On<UI_Update> ("ChartUpdate", dispatch) |> ignore
    (hubConnection.StartAsync()) |> Async.AwaitTask |> Async.Start
    hubConnection    

The connection is hosted in a Component to receive pushed data. (note it took a while for me to sort out all the different pieces to make it all work. Many thanks to others!)

I would appreciate a more elegant solution and integrated solution.
(Also I think hot-reloading stops working when I use SignalR this way)

@Tarmil
Copy link
Member Author

Tarmil commented Mar 17, 2023

I tried using Elmish.Bridge, as it has a .NET client. Unfortunately when I tried to use it, the browser froze. I'm guessing that its direct use of System.Net.WebSockets (as opposed to SignalR.Client) may be the cause.

So I guess a more Bolero-centric, SignalR-based solution will be necessary.

@Tarmil
Copy link
Member Author

Tarmil commented Apr 10, 2023

Endpoint routing is released in v0.22. Another issue can be opened to discuss SignalR.

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

No branches or pull requests

3 participants