Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ public async Task MessageHandler_ShouldReceiveTheNextFrame_GivenOneThatIsNotJson
this.calls.Should().Be(1, "a frame the socket cannot decode must not stop the next one");
}

[TestMethod]
public async Task MessageHandler_ShouldReceiveTheFrame_GivenNoRefBeforeTheFirstHeartbeat()
{
var server = new FakeWebsocketClient();
this.SocketOver(server).AddMessageReceivedHandler((_, _) => this.calls++);
await this.socket.Connect();
server.Receive("""{"topic":"room","event":"broadcast","ref":null,"payload":{}}""");
this.calls.Should().Be(1, "a frame without a ref is not the reply to a heartbeat");
}

[TestMethod]
public async Task StateHandler_ShouldNotStopTheNextHandler_GivenItThrows()
{
Expand Down
2 changes: 1 addition & 1 deletion packages/Realtime/Realtime/RealtimeSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ private void HandleSocketMessage(ResponseMessage args)
Debugger.Instance.Log(this, $"Socket Message Received:\n\t{args.Text}");

// Send Separate heartbeat event
if (decoded!.Ref == this.pendingHeartbeatRef)
if (decoded!.Ref != null && decoded.Ref == this.pendingHeartbeatRef)
{
this.hasPendingHeartbeat = false;
var status = decoded.Payload?.Status == PhoenixStatusOk ? HeartbeatStatus.Ok : HeartbeatStatus.Error;
Expand Down