WebSockets-Sharp Exeption: WebSocketException [closed]
Asked Answered
P

2

7

I made a xamarin iOS/Android Application. This App use websockets-sharp for the comunication with the server.

Now after connecting i got the following error:

03-29 16:11:14.999 I/mono-stdout(19865): 29.03.2018 16:11:14|Fatal|<>c__DisplayClass17.<startReceiving>b__16|WebSocketSharp.WebSocketException: The header of a frame cannot be read from the stream.
29.03.2018 16:11:14|Fatal|<>c__DisplayClass17.<startReceiving>b__16|WebSocketSharp.WebSocketException: The header of a frame cannot be read from the stream.
03-29 16:11:15.005 I/mono-stdout(19865):                             at WebSocketSharp.WebSocketFrame.processHeader (System.Byte[] header) [0x00017] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
                            at WebSocketSharp.WebSocketFrame.processHeader (System.Byte[] header) [0x00017] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
                            at WebSocketSharp.WebSocketFrame+<>c__DisplayClassa.<readHeaderAsync>b__9 (System.Byte[] bytes) [0x00000] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
                            at WebSocketSharp.Ext+<>c__DisplayClass9.<ReadBytesAsync>b__8 (System.IAsyncResult ar) [0x000a2] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
03-29 16:11:15.005 I/mono-stdout(19865):                             at WebSocketSharp.WebSocketFrame+<>c__DisplayClassa.<readHeaderAsync>b__9 (System.Byte[] bytes) [0x00000] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
03-29 16:11:15.006 I/mono-stdout(19865):                             at WebSocketSharp.Ext+<>c__DisplayClass9.<ReadBytesAsync>b__8 (System.IAsyncResult ar) [0x000a2] in <38d3cef14c5a4fc9a92de0991034bc1a>:0 
[0:] Socket is disconected...

Does someone else got this error too and know how to solve this?

Pelagias answered 29/3, 2018 at 14:18 Comment(0)
P
1

Sorry, the problem was in my code...

If you send an event that doesn't exist on the server, this error occures. You can only send events that exists, otherwise it will fail.

Pelagias answered 4/4, 2018 at 7:52 Comment(0)
P
2

Its not the code that is causing error its the mess created by algorithm you have written for the application. The actual error is "The header of a frame cannot be read from the stream" this simply can be caused due to the following issues

Your appliation and server both are sending bulk messages or heavy data at faster rate at the same time to each other. which is well defined and explained here

Solution

You have to optimize your algorithm to meet the following constraints and remove that error

  1. Monitor and Control the data transfer rate to/from the server
  2. Try to wait for the completion of data transfer of one side (Half Duplex)
Phratry answered 3/4, 2018 at 16:50 Comment(0)
P
1

Sorry, the problem was in my code...

If you send an event that doesn't exist on the server, this error occures. You can only send events that exists, otherwise it will fail.

Pelagias answered 4/4, 2018 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.