kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
Apache License 2.0
764 stars 273 forks source link

System.Exception: HTTP/1.1 200 OK #160

Closed Rombersoft closed 4 years ago

Rombersoft commented 5 years ago

This is my code:

public Client()
        {
            _client = new WebSocket("ws://localhost:3000/");
            _client.Opened += Opened;
            _client.Error += Error;
            _client.Closed += Closed;
            _client.MessageReceived += MessageReceived;
        }

        void MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            Console.WriteLine("Message: {0}", e.Message);
        }

        void Closed(object sender, EventArgs e)
        {
            Console.WriteLine("Closed");
        }

        void Error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e)
        {
            Console.WriteLine("Exception: {0}", e.Exception);
        }

        public void Connect()
        {
            _client.Open();
        }

        private void Opened(object sender, EventArgs e)
        {
            Console.WriteLine("Connected");
            BaseRequest request = new BaseRequest("CheckConnection", 0);
            string message = request.ToString();
            Console.WriteLine(message);
            Send(message);
        }

        public void Send(string message)
        {
            _client.Send(message);
        }

When I start application I get this:

Exception: System.Exception: HTTP/1.1 200 OK
Closed
Exception: System.Net.Sockets.SocketException (0x80004005): The socket is not connected
Thread started:  #10
Exception: System.Net.Sockets.SocketException (0x80004005): The socket is not connected
Closed
Exception: System.Net.Sockets.SocketException (0x80004005): The socket is not connected
Exception: System.Net.Sockets.SocketException (0x80004005): The socket is not connected
Exception: System.Net.Sockets.SocketException (0x80004005): The socket is not connected

Why is exception if status 200 OK????

Ubuntu 18.10

Mono 5.2

.Net Framework 4.0

WebSocket4Net.0.15.2

kerryjiang commented 4 years ago

It is not a expected http response. Which websocket server do you use?

Rombersoft commented 4 years ago

This issues in not actual already. I've understood that in order to connect to web-socket server need to add "/bla-bla" after ip + port adress