Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Executing OnError #734

Open
SASIN83 opened this issue Aug 30, 2023 · 0 comments
Open

Not Executing OnError #734

SASIN83 opened this issue Aug 30, 2023 · 0 comments

Comments

@SASIN83
Copy link

SASIN83 commented Aug 30, 2023

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);
}

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant