-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting timeout to TcpClient with SslStream result in terminating connection #4458
Comments
@michaldobrodenka Did you try the code in a console app? If not, please try to see if you will get the same error. From the above stack trace the issue is either in WebSocketSharp (I deem it more likely) or in the Mono BCL. Please let me know what was the result of your investigation with the console app and we'll decide what to do next about the error, thanks! |
@grendello The same code is used in WPF/Windows, iOS and Android, used by thousands of users. |
Android throw an exception if blocking socket operation is done in main thread. (I think) |
@michaldobrodenka It's not Android which throws the exception, but the Mono BCL running on Android - which is why I asked you to test the code in a console app. I failed to mention the app should be ran with Mono. And the reason I asked you to do it, is that there's nothing in |
Cross-referencing note This might not quite match, but maybe the following items about a change in the underlying implementation of
That change from the Mono Framework is present in the Xamarin.Android SDK starting with version 10.2. |
Interesting, I will One "solution" is to not to connect secure. If I string replace wss to ws in connect and allow that in server, everything works normally :) Also it seems, that when I turn off concurent garbage collector, time between disconnects increases. |
Maybe this problem is new version of this bug: This bug has plagued us for years. Will this network code be replaced by NET5 in November? |
@marek-safar can you assign this issue to someone who's maintaining the Mono networking/TLS stack atm? Thanks! |
/cc @steveisok |
@baulig Please take a look and see what you can make of it. |
I'm still trying to narrow down the problem. In small app with websocket-sharp problem doesn't occur. My app has also UDP multicast, UDP broadcast, contacting many restp apis, not only websockets. Maybe something is interfering with sometinhg :) |
Light at the end of the tunnel. It seems that my fork of websocket-sharp is setting Read and WriteTimeout to TcpClient which causes this problem in new Mono. That's probably it, but I'll investigate more tomorrow. |
this I found also in logcat:
|
@michaldobrodenka this warning is harmless. The managed code will find the correct type in the slow way. |
If you want to play with it, I made small Xamarin.Android app which demostrate the problem and flood logcat with this problem every 3 seconds. (uses echo.websocket.org) See class WsConnection, line 50, comment this line and it works normally. |
@grendello
|
If I interpret the stack trace correctly, then On the above stack trace, there's |
@baulig Problem is that up until X.A 10.200 this code was perfectly fine. And is also fine with .NET. And this code is also ok in X.A 10.200, if you don't set Receive/Send Timeouts to TcpClient (or it's socket) |
With support for Classic Xamarin.Android ended May 1st, 2024, this issue is likely no longer relevant. If this still persists in .NET 8+, please open a new issue with updated information based on |
I use websocket-sharp in my App. I tried to compile it with Xamarin.Android 10.2.100.7. (In VS2019 16.4.6 it's ok, so we will have to build release apps with VS2019 16.4.6 until this is fixed)
When I compile and deploy app in Release mode everything works, but every 10-15 seconds websocket connection is lost and has to be recreated. Websocket connection is secure. When connection is dropped: this appears in logcat:
The text was updated successfully, but these errors were encountered: