Skip to content

InvalidDataException on Debian 6.0 but not on Windows 10 #762

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

Closed
Erlite opened this issue Jul 20, 2017 · 2 comments
Closed

InvalidDataException on Debian 6.0 but not on Windows 10 #762

Erlite opened this issue Jul 20, 2017 · 2 comments

Comments

@Erlite
Copy link

Erlite commented Jul 20, 2017

Heya,

I use a package, CoreRCON, which allows me to connect to Source Game Servers to remotely send console commands. On start, my app creates the connections to the servers, and stores them for later. The problem is, one of the rcon server connection throws a System.IO.InvalidDataException on my Debian server, but testing on my Windows PC, no error is thrown. Trying to catch the exception in a try-catch statement doesn't work.

Exception: https://hastebin.com/eyibotehup.css
Server: Linux botsrv 4.5.7-std-3 #1 SMP Tue Jul 12 09:56:30 UTC 2016 x86_64 GNU/Linux

Result on Server:
image

Result on PC:
image

@svick
Copy link
Contributor

svick commented Jul 21, 2017

I think this is a bug in CoreRCON. It assumes that its TCPPacketReceived method will be called for every "packet". But TCP is a stream-based protocol, it does not really have packets (or rather, it uses packets only as an implementation detail), you can't assume that the buffer you receive contains exactly the information you want, not more or less, as is explained in the documentation:

For byte stream-style sockets, incoming data is placed into the buffer until the buffer is filled, the connection is closed, or the internally buffered data is exhausted.

If it seems to work reliably on Windows, then that's probably just luck.

And CoreRCON is also the reason why the exception is uncatchable: it's thrown from TCPPacketReceived, which is the event handler for SocketAsyncEventArgs.Completed. As far as I know, if the handler throws an exception (and doesn't handle it itself), you can't catch it.

@Petermarcu
Copy link
Member

Sounds like @svick has helped conclude there is nothing here to fix in .NET Core. If it gets root caused as an issue in the platform, let us know. I'm going to close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants