I'm trying to get a simple test going with Xamarin and WebSocket4Net but it fails on Open() with "Operation already in progress". Example code below:
using Xamarin.Forms;
using WebSocket4Net;
using System;
using SuperSocket.ClientEngine;
namespace SocketTest
{
public partial class SocketTest : ContentPage
{
private WebSocket websocket;
public SocketTest()
{
InitializeComponent();
}
void Handle_Clicked(object sender, System.EventArgs e)
{
websocket = new WebSocket("ws://echo.websocket.org/");
websocket.Opened += Websocket_Opened;
websocket.Error += Websocket_Error;
websocket.Closed += Websocket_Closed;
websocket.MessageReceived += Websocket_MessageReceived;
websocket.Open();
}
private void Websocket_Error(object sender, ErrorEventArgs e)
{
Console.WriteLine(e.Exception.Message);
}
private void Websocket_MessageReceived(object sender, EventArgs e)
{
Console.WriteLine(e.ToString());
}
private void Websocket_Closed(object sender, EventArgs e)
{
Console.WriteLine(e.ToString());
}
private void Websocket_Opened(object sender, EventArgs e)
{
websocket.Send("Hello World!");
}
}
}
I started with the standard multi-platform project (PCL) and added a button to initiate the connection.
Versions:
0.15.0 WebSocket4Net
0.8.0.13 SuperSocket
The PCL is configured with: .NET Standard Platform = netstandard1.4
I'm fairly new to .NET/Xamarin but have many years of software development behind me.
I've got the same issue with 0.15. Have you tried downgrading to 0.14, and removing SuperSocket?
There's a GitHub issue regarding this problem.
Getting this error when trying to connect in StartReceive()
Here's an excerpt:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With