Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "get to know" an undocumented SignalR server?

Tags:

c#

signalr

I am writing a c# console client to connect to SignalR service of a server. Using a bit of Wiresharking, Firebugging and examining the .../signalr/hubs document on the server, I was able to connect on 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 there available on the server to connect to? (ask for a list of them)
  • What methods can I invoke on the hub? (ask for a list of them)
  • What services can I subscribe to? And what will be the names of the events I will be handling, and the classes of the objects I will be receiving?

The IHubManager interface or HubManagerExtensions class look promising, but I was not even able to find out, what 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!

like image 620
hribayz Avatar asked Oct 18 '22 23:10

hribayz


1 Answers

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

No, SignalR doesn't have something that complex. What you can get, manually, is from the SignalR proxy: ./signalr/hubs.

If you look at this code from the proxy

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 get only:
- hub names (chatHub)
- server methods and number of parameters (serverMethod, 3 parameters)

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

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

The client methods are not really in any list and are used on the fly. You can catch them with Fiddler.

like image 181
Florin Secal Avatar answered Oct 21 '22 17:10

Florin Secal