For a deeper look into our Elektron API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
17.3k 82 39 63

WebSocket API C# example throws exception with batch request

Using the packaged example application written in C# that fetches a batch of items works based on the small sample data set. However, if I change the sample data set to a moderately sized batch of items, the application throws this exception:

Received Log Event (Level: Fatal): WebSocketSharp.WebSocketException: The header of a frame cannot be read from the stream.
   at WebSocketSharp.WebSocketFrame.processHeader(Byte[] header)
   at WebSocketSharp.WebSocketFrame.<>c__DisplayClassa.<readHeaderAsync>b__9(Byte[] bytes)
   at WebSocketSharp.Ext.<>c__DisplayClass9.<ReadBytesAsync>b__8(IAsyncResult ar)

For my tests, it seems the magic number is118 if I don't specify a View. That is, specifying a batch size of 118 items succeeds and 119 consistently fails (throws an exception). For whatever reason, if I do specify a View, the magic number changes to 115.

EDIT: When looking at the ADS log, this is what is produced:

Reason: hipcRead() failed with code 2 and system error 11. Text: <Impl/hipcsrvr.c:2923> Unsupported WebSocket Continuation OpCode
elektron-sdktreprdp-apiwebsocketsrrtobatchexception
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
361 1 4 3

@nick.zincone1

I have reproduced this. WebSocketSharp will fragment messages that are larger than 1016 bytes (that value is hard-coded as "FragmentLength" in its implementation). However, the ADS websocket does not support continuation frames yet. We will address this.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
361 1 4 3

@nick.zincone1

This is likely due to a disconnection. When that happens, WebSocketSharp logs this event and the application should get the OnClose event.

Does the ADS log file give a reason for disconnecting you?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@jim.carroll,

I've updated my original post to include the ADS log. Yes, the application does call the OnClose with the reason: "An exception has occurred while receiving.".

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.