Results 1 to 2 of 2
  1. #1

    Connect to Lightstreamer via web socket c#

    I use the socket net web library in my project. I do not want to use C # LightStreamer.
    I connect to the push server using the following code, but it gives a connection error. I send all the headers but it does not connect to the server

    Code:
    var url = new Uri("wss://push.example.com/lightstreamer");
    var factory = new Func<ClientWebSocket>(() =>
    {
        var client = new ClientWebSocket
        {
            Options =
            {
                KeepAliveInterval = TimeSpan.FromSeconds(5),
                // Proxy = ...
                // ClientCertificates = ...
            }
        };
    
    
        client.Options.SetRequestHeader("Cookie", "_ga=GA1.2.383731026.1594794458; _gid=GA1.2.1818321527.1600487734");
        client.Options.SetRequestHeader("Host", "push.example.com");
        client.Options.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0");
        client.Options.SetRequestHeader("Accept", "*/*");
        client.Options.SetRequestHeader("Accept-Language", "en-US,en;q=0.5");
        client.Options.SetRequestHeader("Accept-Encoding", "gzip, deflate, br");
        
        client.Options.SetRequestHeader("Origin", "https://example.com");
        client.Options.SetRequestHeader("Sec-WebSocket-Protocol", "js.lightstreamer.com");
        client.Options.SetRequestHeader("Sec-WebSocket-Extensions", "permessage-deflate");
        
        client.Options.SetRequestHeader("Pragma", "no-cache");
        client.Options.SetRequestHeader("Cache-Control", "no-cache");              
    
    
        return client;
    });
    
    
    using (IWebsocketClient client = new WebsocketClient(url, factory))
    {
        client.ReconnectTimeout = TimeSpan.FromSeconds(30);
        client.ErrorReconnectTimeout = TimeSpan.FromSeconds(30);
        client.ReconnectionHappened.Subscribe(type =>
        {
            Console.WriteLine($"Reconnection happened, type: {type}, url: {client.Url}");
        });
        client.DisconnectionHappened.Subscribe(info =>
            Console.WriteLine($"Disconnection happened, type: {info.Type}"));
    
    
        client.MessageReceived.Subscribe(msg =>
        {
            Console.WriteLine($"Message received: {msg}");
        });
    
    
        Console.WriteLine("Starting...");
        client.Start().Wait();
        Console.WriteLine("Started.");
    
    
    
    
        ExitEvent.WaitOne();
    }

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,089
    The provided information discloses only part of the client-side processing.
    Unfortunately, we don't know the details of the websocket client implementation that you chose.

    The best way to proceed should be to see Lightstreamer Server log instead.
    Is the involved Server run by you or is it a third-party installation?
    In the latter case, could you grab the exact Server response?

 

 

Similar Threads

  1. Unable to connect via Windows command prompt
    By PBLopez in forum Client SDKs
    Replies: 1
    Last Post: April 16th, 2018, 10:04 AM
  2. Disable StreamSense via Web Client
    By Soot in forum Client SDKs
    Replies: 7
    Last Post: October 17th, 2016, 10:49 AM
  3. Apache as web socket proxy
    By essagl in forum General
    Replies: 0
    Last Post: April 13th, 2014, 10:14 AM
  4. DotNet Client not able to connect via NTLM proxy
    By vpurohit in forum Client SDKs
    Replies: 1
    Last Post: April 29th, 2013, 09:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 12:30 PM.