websocket-sharp icon indicating copy to clipboard operation
websocket-sharp copied to clipboard

Operation is not supported on this platform.

Open yuzhupeng opened this issue 4 years ago • 8 comments

Operation is not supported on this platform. ???what problem

yuzhupeng avatar Feb 24 '21 15:02 yuzhupeng

log:

{ "system": "Meowv.Blog", "datetime": "2021-02-24 23:00:24,733", "description": "binance:System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Action1.BeginInvoke(T obj, AsyncCallback callback, Object object) at WebSocketSharp.WebSocket.open() in C:\Users\Administrator\Desktop\chenxu\websocket-sharp\WebSocket.cs:line 1554 at WebSocketSharp.WebSocket.Connect() in C:\Users\Administrator\Desktop\chenxu\websocket-sharp\WebSocket.cs:line 3235 at GetTradeHistoryData.binanceWebscoket.Start(String senddata) in C:\Users\Administrator\Desktop\chenxu\GetTradeHistoryData\Futures\BINANCE\binanceWebscoket.cs:line 104", "level": "ERROR", "info": "" } { "system": "Meowv.Blog", "datetime": "2021-02-24 23:00:25,725", "description": ":System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Action1.BeginInvoke(T obj, AsyncCallback callback, Object object) at WebSocketSharp.WebSocket.open() in C:\Users\Administrator\Desktop\chenxu\websocket-sharp\WebSocket.cs:line 1554 at WebSocketSharp.WebSocket.Connect() in C:\Users\Administrator\Desktop\chenxu\websocket-sharp\WebSocket.cs:line 3235 at GetTradeHistoryData.binanceUSDWebscoket.Start(String senddata) in C:\Users\Administrator\Desktop\chenxu\GetTradeHistoryData\Futures\BINANCE\binanceUSDWebscoket.cs:line 101", "level": "ERROR", "info": "" } { "system": "Meowv.Blog", "datetime": "2021-02-24 23:02:03,656", "description": "binancewebsocket_Closed", "level": "ERROR", "info": "" } { "system": "Meowv.Blog", "datetime": "2021-02-24 23:02:04,049", "description": "binancewebsocket_Closed", "level": "ERROR", "info": "" } { "system": "Meowv.Blog", "datetime": "2021-02-24 23:03:08,490", "description": ":System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Action`1.BeginInvoke(T obj, AsyncCallback callback, Object object) at WebSocketSharp.WebSocket.open() in C:\Users\Administrator\Desktop\chenxu\websocket-sharp\WebSocket.cs:line 1554 at WebSocketSharp.WebSocket.Connect() in C:\Users\Administrator\Desktop\chenxu\websocket-sharp\WebSocket.cs:line 3235 at GetTradeHistoryData.binanceWebscoket.Start(String senddata) in C:\Users\Administrator\Desktop\chenxu\GetTradeHistoryData\Futures\BINANCE\binanceWebscoket.cs:line 104", "level": "ERROR", "info": "" }

yuzhupeng avatar Feb 24 '21 15:02 yuzhupeng

Are you by chance using .NET Core? I noticed that this issue is specifically related to the fact this project wasn't compiled against Core. I have no problems using .NET Standard.

BossOfGames avatar Apr 12 '21 06:04 BossOfGames

I have this too in .NET 5 WPF

PhilippElhaus avatar Jun 08 '21 18:06 PhilippElhaus

Same here. Winforms, after migrating from .NET Framework to .NET 5.

davlovsky avatar Jul 22 '21 19:07 davlovsky

Switched to the latest NuGet of WebSocket4Net - is similar to code and works just fine.

PhilippElhaus avatar Jul 22 '21 19:07 PhilippElhaus

I had this line in my old code: Websocket.SslConfiguration.ServerCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };

Do you know if there is a WebSocket4Net analog?

davlovsky avatar Jul 22 '21 19:07 davlovsky

One workaround is to use Connect instead of ConnectAsync and Send instead of SendAsync and if that doesn't work for you switch to https://github.com/sipsorcery/websocket-sharp

henon avatar Apr 07 '22 19:04 henon

With a .Net6 project, I used Close instead of CloseAsync and no longer had this error. Using Connect and Send as well, thanks to @henon.

acd450 avatar Jan 18 '24 19:01 acd450