Skip to content

SignalR-ObjC error seek help #294

Description

@rainLiuSkypine

This is my code:
SRHubConnection *hubConnection = [[SRHubConnection alloc] initWithURLString:URL_BASIC useDefault:NO];
hubConnection.delegate = self;

id par = @{@"X-ZUMO-AUTH":[SkUserDefaults readUser].AuthenticationToken};
hubConnection.headers = par;
 _chat = (id)[hubConnection createHubProxy:@"CarGpsHub"];
 [_chat on:@"GpsSite" perform:self selector:@selector(responseMessage:)];
[hubConnection setStarted:^{
    NSLog(@"Connection Started");
}];
[hubConnection setReceived:^(NSString *message) {
    NSLog(@"Connection Recieved Data: %@",message);
}];
[hubConnection setConnectionSlow:^{
    NSLog(@"Connection Slow");
}];
[hubConnection setReconnecting:^{
    NSLog(@"Connection Reconnecting");
}];
[hubConnection setClosed:^{
    NSLog(@"Connection Closed");
}];
[hubConnection setError:^(NSError *error) {
    NSLog(@"Connection Error %@",error);
}];

[hubConnection start];

NSArray *arr = [NSArray arrayWithObject:[SkUserDefaults readCar].DeviceId];
[_chat invoke:@"GpsSite" withArgs:arr completionHandler:nil];

this is server code :
public class CarGpsHub : Hub
{
//[Microsoft.AspNet.SignalR.Authorize]
public void GpsSite(string deviceId)
{

        Clients.Client(this.Context.ConnectionId).GpsSite("连接成功!");
               }

}

but it is receive an error
connection did receive error Error Domain=com.SignalR.SignalR-ObjC.SRHubConnection Code=0 "The connection has not been established" UserInfo={NSLocalizedFailureReason=NSInternalInconsistencyException, NSLocalizedDescription=The connection has not been established}
TRANSPORT: negotiate was successful {
ConnectionId = "6452610a-f649-4b62-91de-cb606f24ac60";
ConnectionTimeout = 18;
ConnectionToken = "5sA+r8urGQRsOd8ZABqFBekMOa+jqNWQJDC+4Hrln/izW7yAL0C4K6gT2cwHXMP/39h/DOpeJJ/HDmxtrIF2iO5+OSFtbCMr+dJAwzlq0lwVkmdV43CWUv8BpZ0pXbbV";
DisconnectTimeout = 6;
KeepAliveTimeout = 4;
LongPollDelay = 0;
ProtocolVersion = "1.3.0.0";
TransportConnectTimeout = 5;
TryWebSockets = 1;
Url = "/signalr";
}
can you give me some advice?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions