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

WebSocketServer.Broadcast throws NullReferenceException v1.6.6.1 #249

Open
darxis opened this issue Sep 27, 2019 · 1 comment
Open

WebSocketServer.Broadcast throws NullReferenceException v1.6.6.1 #249

darxis opened this issue Sep 27, 2019 · 1 comment

Comments

@darxis
Copy link

darxis commented Sep 27, 2019

I am using the SuperSocket.WebSocket NuGet package version 1.6.6.1.

The following code:

var sessions = _webSocketServer.GetAllSessions().ToList();
_webSocketServer.Broadcast(sessions, serializedMessage, (session, sendOk) =>
            {
                if (!sendOk)
                {
                    try
                    {
                        session.Send(serializedMessage);
                    }
                    catch
                    {
                        PolicyHelper.TryOnce(() => session.Close(CloseReason.SocketError));
                    }
                }
            });

sometimes throws NullReferenceException.

Also, could you please tell me if I am using the sendFeedback parameter correctly? I want to make sure that the message is broadcast, so if sendOk is false then I just manually call the session.Send(serializedMessage) method to make sure it will get send (I have observed cases when the sendOk was false and the WebSocketSession was connected and healthy).

I just want to make sure that the message will be broadcast to all clients, so I have to check the sendOk param. Wouldn't it be better if WebSocketServer.Broadcast internally used a new method
void WebSocketSession<TWebSocketSession>.SendRawData(IList<ArraySegment<byte>> segments)
instead of the current
bool WebSocketSession<TWebSocketSession>.TrySendRawData(IList<ArraySegment<byte>> segments)?

@darxis
Copy link
Author

darxis commented Sep 27, 2019

See PR #250

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