Click here to Skip to main content
15,881,044 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I want to connect via web socket in asp.net with c#. I am having client project as a windows application and server project hosted as windows service with local system mode.

I am unable to connect the client to server. If server project is a windows application no such issue.

What I have tried:

Core Code as below:
Connect("ws://10.15.15.80/service.svc");

public async Task Connect(string uri)
     {



         NeSTCommonClass.WriteTextFile(LogPath + Logfilename, "Client:Handshake Connectivity  Process Sending from Client Level Process Starts", true);
         Thread.Sleep(1000); //wait for a sec, so server starts and ready to accept connection..

         // ClientWebSocket webSocket = null;
         try
         {
             webSocket = new ClientWebSocket();
             await webSocket.ConnectAsync(new Uri(uri), CancellationToken.None);
             NeSTCommonClass.WriteTextFile(LogPath + Logfilename, "Client:Handshake Connectivity  Process Sending from Client Level Process Ends", true);


             await Task.WhenAll(Receive(webSocket));



         }
         catch (Exception ex)
         {
             NeSTCommonClass.WriteTextFile(LogPath + Logfilename, "Client:HandShake Connectivity Process Failed: " + ex.Message.ToString() + "", true);


         }
         finally
         {
             if (webSocket != null)
                 webSocket.Dispose();
             //Console.WriteLine();
             //Console.WriteLine("WebSocket closed.");
         }
         NeSTCommonClass.WriteTextFile(LogPath + Logfilename, "Client:Handshake Connectivity  Process Sending from Client Level Process Ends", true);
     }
Posted
Comments
Herman<T>.Instance 4-Jul-18 3:37am    
svc is not a windows service but a service in IIS. Maybe that is why you cannot connect?

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