c# - Invoking SignalR from Postman - Stack Overflow

admin2025-04-18  3

I've been trying to invoke a simple Hub method from my .NET 8 web application, using SignalR.

I know that Postman needs to insert that unicode character at the end of the message, but it gives me a handshake error.

For example, I have this wss call: {"protocol":"json","version":1}

In Postman, it says "connected to wss://localhost:...", I don't see the {} response, although Postman says it's connected.

Then I try to send another message:

{ "arguments": ["just a test"], "target": "HubMethod", "type": 1 }

and I get "An unexpected error occurred during connection handshake."

This example is pretty simple, the same as what we have in the ASP.NET documentation.

Does anybody know how to test it using Postman?

I've been trying to invoke a simple Hub method from my .NET 8 web application, using SignalR.

I know that Postman needs to insert that unicode character at the end of the message, but it gives me a handshake error.

For example, I have this wss call: {"protocol":"json","version":1}

In Postman, it says "connected to wss://localhost:...", I don't see the {} response, although Postman says it's connected.

Then I try to send another message:

{ "arguments": ["just a test"], "target": "HubMethod", "type": 1 }

and I get "An unexpected error occurred during connection handshake."

This example is pretty simple, the same as what we have in the ASP.NET documentation.

Does anybody know how to test it using Postman?

Share edited Mar 26 at 23:39 Lex Li 63.5k11 gold badges124 silver badges161 bronze badges asked Jan 29 at 17:03 MaturanoMaturano 1,0234 gold badges18 silver badges44 bronze badges 3
  • 1 Try including character \u001e at the end of your messages. This might be required for SignalR to interpret the message. – Odrai Commented Jan 29 at 18:54
  • 2 In addition, the next link could be useful: stackoverflow.com/q/56474386/1974344 – Odrai Commented Jan 29 at 18:57
  • Odrai helps us find the reason, the answer below I shared also provide the offical doc and the correct format for you. – Jason Commented Jan 30 at 2:21
Add a comment  | 

1 Answer 1

Reset to default 0

All JSON messages must be terminated by the ASCII character 0x1E (record separator).

Here is the sample message for you. You can copy it from my gist link.

转载请注明原文地址:http://anycun.com/QandA/1744950324a89916.html