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

HubException when using MessagePack in .NET 8 #56502

Closed
1 task done
martinvaner opened this issue Jun 28, 2024 · 5 comments
Closed
1 task done

HubException when using MessagePack in .NET 8 #56502

martinvaner opened this issue Jun 28, 2024 · 5 comments
Labels
area-signalr Includes: SignalR clients and servers Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Status: No Recent Activity

Comments

@martinvaner
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi all, after upgrading to .NET 8 I am experiencing issue with SignalR when using MessagePack. I get Microsoft.AspNetCore.SignalR.HubException : The server closed the connection with the following error: Connection closed with an error. when connecting to server. Everything works fine without MessagePack.

Used nugets:

  • Microsoft.AspNetCore.SignalR.Protocols.MessagePack - version 8.0.6
  • MessagePack by neuecc,aarnott - version 2.5.168

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

Microsoft.AspNetCore.SignalR.HubException : The server closed the connection with the following error: Connection closed with an error.

.NET Version

8.0.204

Anything else?

No response

@BrennanConroy
Copy link
Member

@BrennanConroy BrennanConroy added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Jul 1, 2024
@martinvaner
Copy link
Author

martinvaner commented Jul 3, 2024

@BrennanConroy Thank you for your reply. I am posting full exception on my server side.

Failed writing message. Aborting connection. <s:Microsoft.AspNetCore.SignalR.HubConnectionContext>
MessagePack.MessagePackSerializationException: Failed to serialize System.Collections.Generic.List`1[[XXX.RevisionedValue`1[[XXX.DTO, XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] value.
 ---> System.TypeInitializationException: The type initializer for 'FormatterCache`1' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'FormatterCache`1' threw an exception.
 ---> MessagePack.Internal.InitAccessorInGenericClassNotSupportedException: `init` property accessor XXX.RevisionedValue`1[[XXX.DTO, XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Value found in generic type, which is not supported with the DynamicObjectResolver. Use the AllowPrivate variety of the resolver instead. See https://github.com/neuecc/MessagePack-CSharp/issues/1134 for details.
   at MessagePack.Internal.ObjectSerializationInfo.EmittableMember.ThrowIfNotWritable()
   at MessagePack.Internal.ObjectSerializationInfo.CreateOrNull(Type type, Boolean forceStringKey, Boolean contractless, Boolean allowPrivate, Boolean dynamicMethod)
   at MessagePack.Internal.DynamicObjectTypeBuilder.BuildType(DynamicAssembly assembly, Type type, Boolean forceStringKey, Boolean contractless)
   at MessagePack.Resolvers.DynamicContractlessObjectResolver.FormatterCache`1..cctor()
   --- End of inner exception stack trace ---
   at MessagePack.Resolvers.DynamicContractlessObjectResolver.GetFormatter[T]()
   at MessagePack.Resolvers.ContractlessStandardResolver.FormatterCache`1..cctor()
   --- End of inner exception stack trace ---
   at MessagePack.Resolvers.ContractlessStandardResolver.GetFormatter[T]()
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.SignalRResolver.Cache`1.ResolveFormatter()
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.SignalRResolver.Cache`1..cctor()
--- End of stack trace from previous location ---
   at MessagePack.FormatterResolverExtensions.Throw(TypeInitializationException ex)
   at MessagePack.Formatters.ListFormatter`1.Serialize(MessagePackWriter& writer, List`1 value, MessagePackSerializerOptions options)
   at MessagePack.MessagePackSerializer.Serialize[T](MessagePackWriter& writer, T value, MessagePackSerializerOptions options)
   --- End of inner exception stack trace ---
   at MessagePack.MessagePackSerializer.Serialize[T](MessagePackWriter& writer, T value, MessagePackSerializerOptions options)
   at MessagePack.MessagePackSerializer.SerializeSemiGeneric[T](MessagePackWriter& writer, Object valueObject, MessagePackSerializerOptions options)
   at MessagePack.MessagePackSerializer.Serialize(Type type, MessagePackWriter& writer, Object obj, MessagePackSerializerOptions options)
   at Microsoft.AspNetCore.SignalR.Protocol.DefaultMessagePackHubProtocolWorker.Serialize(MessagePackWriter& writer, Type type, Object value)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteArgument(Object argument, MessagePackWriter& writer)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteCompletionMessage(CompletionMessage message, MessagePackWriter& writer)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteMessageCore(HubMessage message, MessagePackWriter& writer)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocolWorker.WriteMessage(HubMessage message, IBufferWriter`1 output)
   at Microsoft.AspNetCore.SignalR.Protocol.MessagePackHubProtocol.WriteMessage(HubMessage message, IBufferWriter`1 output)
   at Microsoft.AspNetCore.SignalR.HubConnectionContext.WriteCore(HubMessage message, CancellationToken cancellationToken)

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Jul 3, 2024
@BrennanConroy
Copy link
Member

The exception says

MessagePack.Internal.InitAccessorInGenericClassNotSupportedException: init property accessor XXX.RevisionedValue`1[[XXX.DTO, XXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Value found in generic type, which is not supported with the DynamicObjectResolver. Use the AllowPrivate variety of the resolver instead. See MessagePack-CSharp/MessagePack-CSharp#1134 for details.

@BrennanConroy BrennanConroy added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Jul 8, 2024
Copy link
Contributor

Hi @martinvaner. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Status: No Recent Activity
Projects
None yet
Development

No branches or pull requests

2 participants