🎄 Happy Holidays! 🥳

Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.

Happy Holidays!

Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.

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