Skip to content

[SignalR] Could not parse value for header 'User-Agent' #30137

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

Closed
zaksnet opened this issue Feb 12, 2021 · 2 comments · Fixed by #30764
Closed

[SignalR] Could not parse value for header 'User-Agent' #30137

zaksnet opened this issue Feb 12, 2021 · 2 comments · Fixed by #30764
Labels
area-signalr Includes: SignalR clients and servers bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@zaksnet
Copy link

zaksnet commented Feb 12, 2021

Describe the bug

When i try to connect from a Microsoft.AspNetCore.SignalR.Client with a SignalR server i get the following exception:
Failed connecting with the SignalR server: Could not parse value for header 'User-Agent'
What i have found so far is that:

  • This does not happen when i set the transfer protocol to WebSockets AND SkipNegotiation is true ex:
_client = new HubConnectionBuilder()
    .WithUrl($"http://{serverIp}:{port}/client", HttpTransportType.WebSockets, options =>
    {
        options.SkipNegotiation = true;
    })
    .Build();
  • It seems to be related to Mono. I am trying to make this work with Godot game engine which depends on mono.
  • It seems to be related to how the Mono HttpClient serialises the headers?

To Reproduce

Try to connect with a server using mono runtime.

Exceptions (if any)

at bool System.Net.Http.Headers.HttpHeaders.AddInternal(string name, IEnumerable<string> values, HeaderInfo headerInfo, bool ignoreInvalid)
at void System.Net.Http.Headers.HttpHeaders.Add(string name, IEnumerable<string> values) x 2
at HttpClient Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.CreateHttpClient()
at new Microsoft.AspNetCore.Http.Connections.Client.HttpConnection(HttpConnectionOptions httpConnectionOptions, ILoggerFactory loggerFactory)
at async ValueTask<ConnectionContext> Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync(EndPoint endPoint, CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore(CancellationToken cancellationToken)
at async Task Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner(CancellationToken cancellationToken)
at void System.Threading.Tasks.ForceAsyncAwaiter.GetResult()
at async Task Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync(CancellationToken cancellationToken)
at async void IO.Client.Singletons.Connection.ServerConnection.ConnectWithServer() in XXXX

Further technical details

.NET SDK (reflecting any global.json):
 Version:   5.0.200-preview.20614.14
 Commit:    863605c8c3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.200-preview.20614.14\

Host (useful for support):
  Version: 5.0.2
  Commit:  cb5f173b96

.NET SDKs installed:
  2.1.517 [C:\Program Files\dotnet\sdk]
  3.1.402 [C:\Program Files\dotnet\sdk]
  5.0.100-preview.8.20417.9 [C:\Program Files\dotnet\sdk]
  5.0.102 [C:\Program Files\dotnet\sdk]
  5.0.200-preview.20614.14 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.8.20414.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.8.20407.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-preview.8.20411.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

My question is, is there any easy way to overcome this? Like settings custom User-Agent headers from server side?
I would just go with WebSockets but this limits me from using featurs like Authentication and Identities etc.
Thank you.

@javiercn javiercn added the area-signalr Includes: SignalR clients and servers label Feb 12, 2021
@BrennanConroy
Copy link
Member

Triage: We can look at seeing if there is a user provided user-agent before trying to write our own. This way users can set an empty one to avoid SignalR trying to set an "invalid" one.

@BrennanConroy BrennanConroy added this to the Next sprint planning milestone Feb 17, 2021
@ghost
Copy link

ghost commented Feb 17, 2021

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@BrennanConroy BrennanConroy added the bug This issue describes a behavior which is not expected - a bug. label Feb 17, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-signalr Includes: SignalR clients and servers bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants