Skip to content

EnableAffectiveDialog = true causes silent WebSocket close — ReceiveAsync(ArraySegment<byte>, CancellationToken) returns null with no error #263

@kkdubey

Description

@kkdubey

When EnableAffectiveDialog = true is set in LiveConnectConfig, the Gemini server silently closes the WebSocket connection after receiving the setup message. AsyncSession.ReceiveAsync() returns null with no exception or error details, making this extremely difficult to diagnose.
Environment
• Package: Google.GenAI v1.5.0
• Runtime: .NET 8
• Model: gemini-2.5-flash-native-audio-latest

Steps to Reproduce:
using Google.GenAI;
using Google.GenAI.Types;

Client client = new(apiKey: "VALID_API_KEY");

LiveConnectConfig config = new() {
EnableAffectiveDialog = true, // ← causes the issue
ResponseModalities = [Modality.Audio],
SystemInstruction = new Content {
Parts = [new Part { Text = "You are a helpful assistant." }]
},
SpeechConfig = new SpeechConfig {
VoiceConfig = new VoiceConfig {
PrebuiltVoiceConfig = new PrebuiltVoiceConfig {
VoiceName = "Zephyr"
}
}
},
InputAudioTranscription = new AudioTranscriptionConfig(),
OutputAudioTranscription = new AudioTranscriptionConfig()
};

AsyncSession session = await client.Live.ConnectAsync(
"gemini-2.5-flash-native-audio-latest", config);

// This returns null — server closed the connection
LiveServerMessage setupMessage = await session.ReceiveAsync();

Console.WriteLine(setupMessage == null
? "BUG: setupMessage is null — server closed connection silently"
: "OK: SetupComplete received");

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions