如何使用Fleck建立SSL连接

时间:2019-08-09 20:00:38

标签: c# websocket connection-timeout

具有JavaScript客户端:

var ws;
var url = "wss://192.168.0.9:8090/";

$(document).ready(function () {

function Connect() {
    try {
        $("#lblConnectionStatus").html("Reconnecting...");
        if (ws instanceof WebSocket) {
            ws.close();
        }
        ws = new WebSocket(url);
        ws.binaryType = "arraybuffer";
        ws.onerror = function (e) {
            $("#divInternalMessangingStatus").html("Internal Messaging Error: ");//+ e.message);
        };
        ws.onclose = function () {
            $("#divInternalMessangingStatus").html("Internal Messaging Closed:");
            Connect();
        };
        ws.onopen = function () {
            $("#divInternalMessangingStatus").html("Client connected");

        };
        ws.onmessage = function (e) {
            $("#divInternalMessangingStatus").html(e.data);
        };
    } catch (err) {
        $("#divInternalMessangingStatus").html(err);
    }
}


Connect();
});

我的服务器是:

public static void Start()
{
    var server = new WebSocketServer( "wss://0.0.0.0:8090/" );
    server.Certificate = new X509Certificate2( "localhost.crt" );
    server.EnabledSslProtocols = SslProtocols.Tls;

     server.Start(

        socket =>
        {
            try
            {
                socket.OnOpen = () => { Logger.LogVerbose( LoggerNames.InternalMessanger, "OnOpen" ); };
                socket.OnClose = () => { Logger.LogVerbose( LoggerNames.InternalMessanger, "OnClose"); };
                socket.OnMessage = message => { Logger.LogVerbose( LoggerNames.InternalMessanger, "OnMessage"); };
            }
            catch ( Exception e )
            {
                Logger.LogVerbose( LoggerNames.InternalMessanger, e.ToString() );
            }
        } );    
}

localhost.crt是使用OpenSSL创建的,并且已正确加载。

我在客户端收到消息“超时”。

我想念什么?

0 个答案:

没有答案