DyKnow / SignalR-ObjC

Objective-C Client for the SignalR Project works with iOS and Mac
MIT License
442 stars 213 forks source link

SignalR-ObjC error seek help #294

Open rainLiuSkypine opened 7 years ago

rainLiuSkypine commented 7 years ago

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?

SSDABSiddique commented 4 years ago

I am also facing same message. "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}"