sta / sta/websocket-sharp

Not Executing OnError

Open
#734 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

When I was testing the code from the sample I intentionally added a wrong URL but instead of OnError it triggers OnClose, is this the normal behavior or is something wrong

`
public class NotiSocket
{
private WebSocketSharp.WebSocket m_webSocket;
public NotiSocket()
{
m_webSocket = new WebSocketSharp.WebSocket("ws:///notisocket/noti");
m_webSocket.OnMessage += m_webSocket_OnMessage;
m_webSocket.OnError += m_webSocket_OnError;
m_webSocket.OnOpen += m_webSocket_OnOpen;
m_webSocket.OnClose += m_webSocket_OnClose;
m_webSocket.Connect();
Console.ReadLine();
}

private void m_webSocket_OnClose(object sender, WebSocketSharp.CloseEventArgs e)
{
    Console.WriteLine("Disconnected to websocket server.");
}

//error on websocket
private void m_webSocket_OnError(object sender, WebSocketSharp.ErrorEventArgs e)
{
    Console.WriteLine(e.Message);
}

//connected to websocket server
private void m_webSocket_OnOpen(object sender, EventArgs e)
{
    Console.WriteLine("Connected to websocket server");
    //m_webSocket.Send("Hello");
}

//receive msg from websocket server
private void m_webSocket_OnMessage(object sender, WebSocketSharp.MessageEventArgs e)
{
    Console.WriteLine(e.Data);
}

}
`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WebSocket.Connect() call and the OnError and OnClose handlers in the sample shown. Reproduce the behavior using the intentionally invalid URL and record which events fire; done means the expected event behavior is established or the behavior is narrowed to a reproducible library defect.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.