System.Net.Sockets.SocketException when creating a network connection

iam new in websocket. I created a console application in .net 4.5 shell and create a sample websocket client using the "WebSocketSharp" library. I have the following code

using System;
using WebSocketSharp;


namespace WebsocketTest
{
    class Program
    {
        public static void Main(string[] args)
        {
            try
            { 
            using (var ws = new WebSocketSharp.WebSocket("ws://192.168.18.186:7884"))
            {
               Console.WriteLine("started");
                ws.Connect();
                ws.Send("START");
                Console.ReadLine();
                }
            }catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }

        }
    }
}

But I cannot create a connection to my websocket server running on another machine. I got an error like this

09-05-2017 16:20:41|Fatal|WebSocket.connect:0|System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 192.168.18.186:7884
                             at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
                             at WebSocketSharp.WebSocket.setClientStream()
                             at WebSocketSharp.WebSocket.doHandshake()
                             at WebSocketSharp.WebSocket.connect()

What is the problem with my code? are there any good web layout libraries?

+4
source share
1 answer

, , - -, , , . , telnet - - ( http 1.1), SSL, . telnet : .

telnet , , . -, .NET, (ClientWebSocket)

+1

Source: https://habr.com/ru/post/1676737/


All Articles