Skip to content

WSS Configuration #133

@AlhasanDeveloper

Description

@AlhasanDeveloper

Greetings,

I am trying to connect using WSS but I keep on receiving gibberish data when reading.

Here is the code for starting the server

CancellationTokenSource cancellation = new CancellationTokenSource();
var server = new WebSocketListener(new IPEndPoint(IPAddress.Loopback, Config.WSPort), config.WSOptions);
var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(server);
server.Standards.RegisterStandard(rfc6455);
WebSocketSecureConnectionExtension tls = new WebSocketSecureConnectionExtension(Config.privateKeyServerAuthentication);
server.ConnectionExtensions.RegisterExtension(tls);
server.Start();

as for configuration

WSPort = 8443;
WSOptions = new vtortola.WebSockets.WebSocketListenerOptions(){
   PingTimeout = System.Threading.Timeout.InfiniteTimeSpan,
   NegotiationQueueCapacity = Environment.ProcessorCount * 128,
   ParallelNegotiations = Environment.ProcessorCount * 16,
   NegotiationTimeout = TimeSpan.FromSeconds(5),
   WebSocketSendTimeout = TimeSpan.FromSeconds(5),
   WebSocketReceiveTimeout = TimeSpan.FromSeconds(5),
   SendBufferSize = 16384,
   OnHttpNegotiation = null,
   UseNagleAlgorithm = false,
   PingMode = vtortola.WebSockets.PingModes.LatencyControl
};

as for receiving data

String msg = String.Empty;
WebSocketMessageReadStream messageReadStream = await ws.ReadMessageAsync(token);
if (messageReadStream.MessageType == WebSocketMessageType.Text)
{
   var msgContent = string.Empty;
   using (var sr = new StreamReader(messageReadStream, Encoding.UTF8))
      msgContent = sr.ReadToEnd();
      msg = msgContent;
}

There is no problem with what the server sends to the client but my problem is with receiving the data it is always gibberish, am I doing something wrong here?

Thanks.

Edit:
I am new to commenting in github just highlighted codes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions