How to "recognize" an undocumented SignalR server?

I am writing a C # console client to connect to the server's SignalR service. Using a bit of Wiresharking, Firebugging and studying the document ... / signalr / hubs on the server, I was able to connect to the default "/ signalr" URL:

var connection = new HubConnection("https://www.website.com"); var defaultHub = connection.CreateHubProxy("liveOfferHub"); connection.Start().ContinueWith(task => { if (task.IsFaulted) { Console.WriteLine("Error opening the connection:" + task.Exception.GetBaseException()); } else { Console.WriteLine("SignalR Connected"); } }).Wait(); 

Now i need to find out

  • What hubs are available on the server to connect? (ask for their list)
  • What methods can I call on the hub? (ask for their list)
  • What services can I subscribe to? And what are the names of the events that I will process and the classes of objects that I receive?

The IHubManager interface or the HubManagerExtensions class look promising, but I could not even find out which classes implement it and how to use it. Asp.net/signalr offers only basic documentation and tutorials.

Thanks in advance for pointing me in the right direction!

+5
source share
1 answer

I think what you are looking for is something like WSDL for SignalR.

No, SignalR does not have anything complicated. What you can get manually from SignalR proxy: ./signalr/hubs .

If you look at this code from a proxy server

 proxies.chatHub = this.createHubProxy('chatHub'); //hub name proxies.chatHub.client = { }; proxies.chatHub.server = { serverMethod: function (firstParameter, secondParameter, thridParameter) { //hub method and number of parameters return proxies.chatHub.invoke.apply(proxies.chatHub, $.merge(["ServerMethod"], $.makeArray(arguments))); } }; 

you only get:
- chatHub names ( chatHub )
- server methods and number of parameters ( serverMethod , 3 parameters)

So, the only information that your hub looks something like this:

 [HubName("chatHub")] public class ?? : Hub { public ?? ServerMethod(?? firstParameter, ?? secondParameter, ?? thridParameter) { ?? } } 

Client methods are not actually listed and are used on the fly. You can catch them fiddler .

+3
source

Source: https://habr.com/ru/post/1234702/


All Articles