-
Notifications
You must be signed in to change notification settings - Fork 447
messagepack GUID failing #1043
Comments
Likely a bug or a limitation. Needs some investigation. |
How are you passing the GUID to the hub from Typescript/Javascript? I could be wrong but it looks like the server is expecting the value from the client to be 16 bytes but the client is probably sending a string instead since a GUID in Typescript/javascript is usually represented by a string. |
That's correct, and i believe that is the issue. There is no native GUID in JS/TS (as you've said) so i can do something like:
"serverSomething" will fail, despite having a "proper" guid pushed out to it with the error message above. As you've said before as there's nothing in JS/TS to turn this into a proper guid such that messagepack will see it as such, it will fail despite having a proper guid passed back to it. I guess this is a limitation, though it is interesting why it is throwing that particular error given that it is a properly formatted guid in the first place. I'm unsure as to why this is happening which is why i've raised it here. I'd guess it is not an issue with signalr, but messagepack itself. For now, using it as a string and converting to a guid server-side is fine. I'll continue to investigate if i get the time to try and find a fix. I've done some pretty extensive testing with messagpack/signalr (alpha 2) and this is the first issue that i've run into really. Other than that its been great! Thanks again |
This is a bit tricky. I just merged a change where it is possible to send bytes from the JavaScript client to the server by creating a Uint8Array. So if you have a GUID on the client side you can do |
I don't think there is any work to be done here. I opened an issue in the msgpack-cli repo to ask if they can serialize GUIDs as bin8. If they did handling guids in JS would be quite easy because they would be serialized to Uint8Array/Buffer. Using |
I know this has been marked as closed now. I might be wrong here but i swear i remember reading through and seeing signalr using reflection to get the target types, target args, etc. etc. of the hub methods. Would it not be better to throw an exception stating that GUID is not supported and to use a string instead (assuming a hub method has a System.Guid as an argument)? It would save a lot of people a lot of headaches further down the line if they had this passed to their clients i'm sure |
It depends on what your client is. If you are using C# client it will work just fine. Note that JavaScript does not have a built-in GUID type and this by itself should be a warning sign that the user needs to understand how serialization/deserialization would work for their case. I think we will need to have some documentation on this. |
As per this issue - if MsgPack-Cli - respects CompatibilityOptions and GUIDs are serialized as |
Hi,
When i have a function inside a hub such as the following:
And am using the messagepack protocol on the browser, I get the following error thrown in DeserializeObject (UnpackFrom) in MessagePackHubProtocol.cs:
When I change "ID" in my hub function to be a string, and then manually parse the GUID, it is fine, and there are no problems with anything. Am i doing something wrong here, or is this a bug?
Thanks!
The text was updated successfully, but these errors were encountered: