当我恢复连接的响应时,我收到以下错误
Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 400" UserInfo=0x7f9bb8492a80 {NSLocalizedRecoverySuggestion=The ConnectionId is in the incorrect format., NSErrorFailingURLKey=http://63.134.216.208:8050/signalr/signalr/send?transport=serverSentEvents&connectionToken=EUbfqwHFksD0ygZmJR6Mgjd/RD39nkuXol/o7XoC+yxiqoZN8Ge197elXcig1/2zrurVr32Iir3w6M6J0TX9HrTib+tvHvGFoEyvxHyRFrv4S4LaDXe2rV4nAV8Kmjgq, AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest: 0x7f9bb8422810> { URL: http://63.134.216.208:8050/signalr/signalr/send?transport=serverSentEvents&connectionToken=EUbfqwHFksD0ygZmJR6Mgjd/RD39nkuXol/o7XoC+yxiqoZN8Ge197elXcig1/2zrurVr32Iir3w6M6J0TX9HrTib+tvHvGFoEyvxHyRFrv4S4LaDXe2rV4nAV8Kmjgq }, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x7f9bb8622200> { URL: http://63.134.216.208:8050/signalr/signalr/send?transport=serverSentEvents&connectionToken=EUbfqwHFksD0ygZmJR6Mgjd/RD39nkuXol/o7XoC+yxiqoZN8Ge197elXcig1/2zrurVr32Iir3w6M6J0TX9HrTib+tvHvGFoEyvxHyRFrv4S4LaDXe2rV4nAV8Kmjgq } { status code: 400, headers {
"Cache-Control" = "no-cache";
"Content-Type" = "text/html";
Date = "Tue, 01 Sep 2015 09:54:36 GMT";
Expires = "-1";
Pragma = "no-cache";
Server = "Microsoft-IIS/8.5";
"Transfer-Encoding" = Identity;
"X-AspNet-Version" = "4.0.30319";
"X-Content-Type-Options" = nosniff;
"X-Powered-By" = "ASP.NET";
} }, NSLocalizedDescription=Expected status code in (200-299), got 400}
我的代码如下 在这里我设置代理和网址但仍然
@interface ViewController ()
{
SRHubProxy *chat ;
SRHubConnection *hubConnection;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Connect to the service
hubConnection = [SRHubConnection connectionWithURL:@"http://63.134.216.208:8050/"];
// Create a proxy to the chat service
hubConnection.delegate=self;
chat = [hubConnection createHubProxy:@"chatHub"];
[chat on:@"addMessage" perform:self selector:@selector(addMessage:)];
// Start the connection
[hubConnection start];
hubConnection.started = ^{
NSLog(@"started");
};
hubConnection.received = ^(NSString * data) {
NSLog(@"%@",data);
NSError *jsonError;
self.txtView.text=data;
NSData *objectData = [data dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData
options:NSJSONReadingMutableContainers
error:&jsonError];
};
// Do any additional setup after loading the view, typically from a nib.
}
- (void)addMessage:(NSString *)message {
// Print the message when it comes in
// NSLog(message);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Connect:(id)sender {
// [hubConnection start];
[chat invoke:@"Connect" withArgs:@[@"08434ede-005e-4c05-b78f-4a703086660c",@"Dest",@"Are you there"] completionHandler:^(id response) {
//
}];
}
#pragma mark- delgeates
- (void)SRConnectionDidOpen:(SRConnection *)connection
{
//AQSK
NSLog(@"get connected using HubConnection");
self.txtView.text=@"get connected using HubConnection";
[chat invoke:@"Connect" withArgs:[NSArray arrayWithObjects:@"Connect", nil]];
}
- (void)SRConnection:(SRConnection *)connection didReceiveData:(NSString *)data
{
//AQSK
self.txtView.text=@"data recieved";
self.txtView.text=data;
NSLog(@"data recieved %@",data);
}
- (void)SRConnectionDidClose:(SRConnection *)connection
{
self.txtView.text=@"close";
NSLog(@"close");
}
- (void)SRConnection:(SRConnection *)connection didReceiveError:(NSError *)error
{
self.txtView.text=[NSString stringWithFormat:@"%@",error.description];
NSLog(@"error%@",error.description);
}
- (IBAction)quit:(id)sender {
exit(0);
}
如果你真的知道这里有什么问题,请帮忙。