Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
402 stars 145 forks source link

Websocket use with .net 7 #591

Open simone-gasparini opened 3 months ago

simone-gasparini commented 3 months ago

We have tested the library, with some modifications, and it seems to work. Is there any limitation or problem? Why is limited to NETFX? ConnectionFactory.cs#L157

xinchen10 commented 2 months ago

The WebSockets APIs were not available in the netstandard targes. It was provided as extended NuGet packages. We have a separate package, AMQPNetLite.WebSockets, which can be referenced in your project. After that you can have the following code to use it with addresses starting with "ws" or "wss".

            var connectionFactory = new ConnectionFactory(new TransportProvider[] { new WebSocketTransportFactory() });
            Connection connection = await connectionFactory.CreateAsync(wsAddress);

With the newer .net version it may be different but that would require the library to add a new target framework where websockets can be enabled.