sta / sta/websocket-sharp

Errors receiving should not be fatal?

Aperta
#421 1 commento 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C#
Stelle
6.1k
Fork
1.7k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi,

Occassionally using the client I receive a header that triggers the following exception:
private static WebSocketFrame processHeader (byte[] header)
{
if (header.Length != 2)
throw new WebSocketException ("The header of a frame cannot be read from the stream.");

This raises a fatal error which doesn't seem handleable by my encapsulating code because the method that initialises the client has finished and the error is caught before the OnMessage event is raised.

It also seems that fatal errors do not raise the OnError event.

This leaves me in the situation that a potenetially recoverable error is not handled and halts my datafeed in my windows service.

I have altered the code above processHeader() to treat this exception as an error rather than fatal, and in the event handler for OnError I simply ditch the object and reinitialise. For me this works great but I'm not always keen on modifying libraries and this seems like it might be something to consider for an architectural change?

Unless of course I'm doing something wrong and ther is a proper way to handle this?

Thanks for the hard work on the library, it sped up my dev time no end.

Cheers,
Ashley

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Start by tracing processHeader and the client’s OnError and OnMessage event flow described in the issue, including where client initialization returns. Reproduce the short-header case and define done as making recoverable receive errors observable through the documented handling path without terminating the data feed.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.