Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to pass Url
parameters of a json string for handshaking via
Web Socket in c#. The uri contains query string parameters and it is a json string.While trying to connect I am getting the exception that the URI scheme is not valid

Current WSI Url not working:
("wss://10.15.1.1/Test/sample/{038}?entityDetails={"requestData":"test","requestkData": "tested"}")

WSI uri if as below it works, but without the parameters if passed to the server it works.
"wss://10.15.1.1/Test/sample/

What I have tried:

Core Connectivity Code is as below:
#region Connect
      public async Task Connect(string uri)
      {


          Thread.Sleep(1000); //wait for a sec, so server starts and ready to accept connection..

          try
          {

              webSocket = new ClientWebSocket();

              await webSocket.ConnectAsync(new Uri(uri), CancellationToken.None);


          }
          catch (Exception ex)
          {



              throw ex;



          }
          finally
          {
              if (webSocket != null)
                  webSocket.Dispose();

          }



      }
      #endregion
Posted
Comments
F-ES Sitecore 24-Jul-18 4:39am    
You need to encode the entityDetails data. You don't show how the uri is built so it's hard to suggest what you need to change, but you need to call UrlEncode on the entityDetails param when you are building the uri.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900