SuperSocket.ClientEngine
SuperSocket.ClientEngine copied to clipboard
Getting this error when trying to connect in StartReceive()
I have a live mobile app using Xamarin.Forms and the iOS version works fine but on Android I can't get past this error. Any advice on how to debug this?
"System.InvalidOperationException: Operation already in progress\n at System.Net.Sockets.SocketAsyncEventArgs.SetLastOperation (System.Net.Sockets.SocketAsyncOperation op) [0x00021] in
Which version of ClientEngine do you use right now?
Not sure about ClientEngine version but I am using WebSocket4Net dll v4.0.30319. How do I get the ClientEngine version to check it?
v4.0.30319? It doesn't seem like a product version. It might be the .net framework version.
Oh maybe this is it?
0.14.1.0
Yes, it is.
Could you try the latest version 0.15? Can you use .netstandard library in your project?
Can you link the most recent version, not showing up in NUGET? Thanks in advance
Nevermind found it
Ok I added the most recent version did a clean and build, restarted visual studios and same error is still occurring.
My project is using .net4.5, and it was working great for several months.
I went to Hockey App to get the crash log there as well:
Xamarin caused by: android.runtime.JavaProxyThrowable: System.NotImplementedException: The method or operation is not implemented.
System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure(Exception exception, int bytesTransferred, SocketFlags flags)
I am still working on this issue. I have narrowed it down further and I believe the issue is with Android and using the DNS host name (which crashes )as opposed to an IPaddress (which works).
Is there a good approach allow me to reproduce it?
What I think may be happening is a timeout on the connection, which occurs after just a few milliseconds on the android end. So I have to find a way to adjust the android timeout.
I also get the stack trace @jphoc13 reported on Sep. 19 (4 comments up) in my Xamarin app on Android:
- app uses WebSocket4Net 0.15 with SuperSocket client 0.8.0.13 to connect to Pusher.com
- works properly so long as device has a network connection
- exception occurs immediately when device goes into airplane mode
If I downgrade to WebSocket4Net 0.14.1 and remove the SuperSocket library, the app does not crash, and is able to disconnect/reconnect when network comes and goes. The Pusher library I'm using is quite old, so it may need to be updated to work with 0.15.0.
As @jphoc13 stated above, it works with IP address and does not work with Host name. I am experiencing the same issue on Xamarin.Android project using SocketIoClientDotNet 1.0.3 with WebSocket4Net 0.15.
Could you try adding this environment variable in the application?
Environment.SetEnvironmentVariable("PREFER_DNS_IN_ADVANCE", true);
I've got the same issue and used to work fine in 0.14 on Xamarin. I've also found this question on StackOverflow asking the same question. WebSocket4Net simple example fails with “Operation already in progress”
Did you try this
Environment.SetEnvironmentVariable("PREFER_DNS_IN_ADVANCE", true);
It is the solution for the error System.NotImplementedException: The method or operation is not implemented
I can't seem to code around it with 0.15.1
Environment.SetEnvironmentVariable("PREFER_DNS_IN_ADVANCE", "true", EnvironmentVariableTarget.Machine);
_ws = new WebSocket4Net.WebSocket(uri: Url);
_ws.Open();
_ws.Opened += _ws_Opened;
_ws.Error += _ws_Error;
_ws.Closed += _ws_Closed;
_ws.MessageReceived += _ws_MessageReceived;
I get Operation in progress error immediately after connecting.
Wondering whether this is a bug in .NET
https://github.com/dotnet/corefx/pull/24055 https://github.com/dotnet/corefx/issues/24002
This is working for me after updating to 0.15.2 and SuperSocket 0.10. Now I am able to enter/exit airplane mode without the app crashing. I do not have the PREFER_DNS_IN_ADVANCE environment setting.
Thanks @kerryjiang !
Really? In Xamarin?
Get Outlook for iOShttps://aka.ms/o0ukef
From: Eric Hedstrom [email protected] Sent: Saturday, February 24, 2018 4:09:22 PM To: kerryjiang/SuperSocket.ClientEngine Cc: Kerry Jiang; Mention Subject: Re: [kerryjiang/SuperSocket.ClientEngine] Getting this error when trying to connect in StartReceive() (#72)
This is working for me after updating to 0.15.2 and SuperSocket 0.10. Now I am able to enter/exit airplane mode without the app crashing. I do not have the PREFER_DNS_IN_ADVANCE environment setting.
Thanks @kerryjianghttps://github.com/kerryjiang !
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/kerryjiang/SuperSocket.ClientEngine/issues/72#issuecomment-368270751, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAb1fHoKVW6LzjiZfR_Sam2ERCMey7FUks5tYKSygaJpZM4Pc2rB.
This looks to be the underlying issue in the following: https://github.com/Quobject/SocketIoClientDotNet/issues/133 https://github.com/Quobject/SocketIoClientDotNet/issues/134 https://github.com/Quobject/SocketIoClientDotNet/issues/137
@whybe94 why the thumbs down? These all look to be the same issue.