Solace Community is getting a facelift!

On March 3rd we will be starting the process of migrating Solace Community to a new platform. As a result, Solace Community will go in to a temporary read-only state. You will still be able to come onto Solace Community and search through posts to find answers, but you won't be able to ask questions, post comments, or react in any way.

We hope to have the migration complete by Wednesday March 5th (or sooner), so please keep an eye out!

Native C# Client for Web Sockets

cghersi
cghersi Member Posts: 1
edited March 2022 in PubSub+ Event Broker #1

Hi all!

I need to connect via WebSockets to an on-prem Solace Broker from my native app (UWP written in C#).

I also need to add I the Connect() HTTP request a specific HTTP Header "Authorization" with a Bearer token that I generate in the app.

I cannot see a way to configure the Solace C# SDK to perform such a custom activity, so first of all, do you know any way to do this with the Solace SDK?

Alternatively, I could write a simple native WebSocket without using the Solace SDK, but I need the parameters to connect.

E.g. I tried using a very simple approach (using a NuGet package https://github.com/PingmanTools/websocket-sharp/) like this:

using WebSocketSharp;
WebSocket ws = new WebSocket("wss://mr-bqdpohy3bis.messaging.solace.cloud:443");  
ws.SetCredentials("solace-cloud-client", "<myPsw>", true); 
ws.Connect();

but it doesn't work...

What am I missing?

Thanks!!

cghersi

Tagged:

Answers

  • Ragnar
    Ragnar Member, Employee Posts: 67 Solace Employee

    Hi,

    Why do you have a need to set the bearer token? The web-socket connection is between your client and the broker and the broker has no requirement for a bearer token? You authenticate with the broker via usename/password (as in your websocket only sample), or with kerberos token, or with x.509 client certificate. The latest APIs and broker also support OAUTH2.0. In all of these case the authentication parameters can be supplied as properties on session create.

    Regards,

    Ragnar

This Month's Leaders

This Week's Leaders