Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/FeatBit.ServerSdk/Transport/WebSocketTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,16 @@ public async Task StartAsync(
private static async Task<WebSocket> DefaultWebSocketFactory(Uri uri, CancellationToken cancellationToken)
{
var webSocket = new ClientWebSocket();

// reference: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/clients/csharp/Http.Connections.Client/src/Internal/WebSocketsTransport.cs#L98-L105
// Full Framework will throw when trying to set the User-Agent header
// So avoid setting it in netstandard2.0 and only set it in netstandard2.1 and higher
#if !NETSTANDARD2_0 && !NETFRAMEWORK
webSocket.Options.SetRequestHeader("User-Agent", HttpConstants.UserAgent);
#else
// Set an alternative user agent header on Full framework
webSocket.Options.SetRequestHeader("X-FeatBit-User-Agent", HttpConstants.UserAgent);
#endif

try
{
Expand Down