Reputation: 64221
I have sites on 2 domains:
b.com hosts the SignalR Hub, and a.com tries to create a connection to b.com.
client JS:
var connection = $.hubConnection('http://b.com/');
var notificationHubProxy = connection.createHubProxy('notificationHub');
$.connection.hub.logging = true;
notificationHubProxy.client.resultReceived = function (result) {
console.log(result);object.
}
server eventHub:
public class NotificationHub : Hub
{
public void Hello()
{
Clients.All.hello();
}
public string Echo()
{
return "Notification hub is running normally";
}
}
But I always get the following error on the client page:
SCRIPT5007: Unable to set property 'resultReceived' of undefined or null reference.
As I checked, the 'notificationHubProxy.client' is undefined.
Where is wrong?
Upvotes: 0
Views: 209
Reputation: 3425
This is not a cross-domain issue. You are mixing the dynamic proxy and proxyless approaches. $.hubConnection
and createHubProxy
are from the proxyless API, but .client
is available only with dynamic proxies. Check the documentation about both and you will be able to fix it (I don't go further with code because I do not know which approach you really want to use).
Upvotes: 1