Hey together,
currently I'm trying to connect my Xamarin Forms App to an Socket.io Websocket. I tried differend Websockets, but not any Websocket did work. So no connecting is opended.
My Code (in PCL) looks like this:
`private void ConnectSocket(string nodeJsDomainUrl, int nodeJsPort, string nodeJsUrlAppendix)
{
var options = new Quobject.SocketIoClientDotNet.Client.IO.Options
{
Port = this.telConfig.NodeJsPort,
Hostname = this.telConfig.NodeJsDomainUrl,
IgnoreServerCertificateValidation = true,
Secure = this.telConfig.NodeJsDomainUrl.StartsWith("https")
};
var uri = this.telConfig.NodeJsDomainUrl + ":" + this.telConfig.NodeJsPort;
if (!string.IsNullOrWhiteSpace(this.telConfig.NodeJsUrlAppendix))
{
uri = uri + "/" + nodeJsPort + this.telConfig.NodeJsUrlAppendix;
}
var manager = new Quobject.SocketIoClientDotNet.Client.Manager(new Uri(uri), options);
if (this.socket != null)
{
this.socket?.Disconnect();
this.socket?.Close();
this.socket = null;
}
Log.Warning("Debug", "Start Connection");
this.socket = new Quobject.SocketIoClientDotNet.Client.Socket(manager, "/");
this.socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_CONNECT, this.OnSocketConnected);
this.socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_DISCONNECT, this.OnSocketDisconnected);
this.socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_MESSAGE, this.OnSocketMessage);
this.socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_ERROR, this.OnSocketError);
this.socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_CONNECT_ERROR, this.OnSocketError);
this.socket.On(Quobject.SocketIoClientDotNet.Client.Socket.EVENT_CONNECT_TIMEOUT, this.OnSocketError);
Log.Warning("Debug", "Tried Connection");
}`
When using github.com/Quobject/SocketIoClientDotNet/
This package code doesn't work, I think due to a wrong target framework version (.Net Framework 4.6 instead of .Net Standard 2.0)
My uri looks like "https: //websocket-link:443".
When i try a different nuget package like github.com/NVentimiglia/Websockets.PCL there appears this issue github.com/NVentimiglia/Websockets.PCL/issues/16 so i can't use it.
Does anybody know another Websocket that is compatible with Xamarin Forms and Socket.IO?
It's important that https is supported and selfsigned certificates can be allowed.
Thanks for helping in advance!