mkjeff / secs4net

SECS-II/HSMS-SS/GEM implementation on .NET
https://mkjeff.github.io/secs4net/
MIT License
443 stars 195 forks source link

Receiving large reply message #24

Closed kelvinMyh closed 3 years ago

kelvinMyh commented 6 years ago

hi Jeff I was running the EAPhost, after sending an S1F3 requesting all SVs, the eq replied with over 400 items, and after receiving the first buffer (0x4000 bytes), the program stopped responding to any action, and soon ended itself. I tried to use some try catches, but none break point in the exception section was spotted. appreciation for any reply.

a-v-kalabuhov commented 5 years ago

The list data items in SecsMessage are limited up to 255 elements. It may be a reason why the program did crash.

BinaryAssault commented 5 years ago

I ran into this issue (or at least something similar) and was able to get a workaround. I was receiving a reply message that was very big (list of >55000). Problem was, the ReceiveBufferSize in the SecsGem class was too small. I am not a creator of the SW I am working on, so I cannot give code snippets.

But if you change the ReceiveBufferSize for the socket to accommodate your data on instantiation, it should continue to work.

a-v-kalabuhov commented 5 years ago

it should continue to work.

Thank you very much!

dzhydaniel commented 5 years ago

kelvin,can you share how to start up EAP Host

a-v-kalabuhov commented 5 years ago

BinaryAssault, I meant there is a hardcoded limitation in secs4net. It's just not possible to add to a message a list with more than 255 elements, because the library throws an exception.

   private Item(IReadOnlyList<Item> items)
   {
       if (items.Count > byte.MaxValue)
           throw new ArgumentOutOfRangeException(nameof(items) + "." + nameof(items.Count), items.Count,
               @"List items length out of range, max length: 255");
   ...
   }

But array item length isn't limited.

TiltonJH commented 5 years ago

Well the issue is in the type, where the 2 last Bits determine the size of the length value. Secs supports up to 3 Byte for length value. Secs4Net only ever uses 1 Byte.

The issue should mostly be within the Item class.

If no one else will fix this. I will. But not within the next month. I currently don't got the time.

TiltonJH commented 5 years ago

I have created a pull request (#37), which fixes this issue.

Or have a look here: https://github.com/TiltonJH/secs4net

a-v-kalabuhov commented 5 years ago

I have created a pull request (#37), which fixes this issue.

Or have a look here: https://github.com/TiltonJH/secs4net

Thanks!

mkjeff commented 3 years ago

Thanks for @TiltonJH contribution. I'm happy to see the fork.

btw, welcome to taste v2