title: SignalR ObjC returns "bad response code from server 403" when using WebSockets
body: <p>I am trying to set up an iOS client to use SignalR-ObjC with our web service.  When we use the long polling approach, everything seems to work but it has issues of its own with our production environment.  So I have been instructed to switch to using the Web Sockets approach. Based on code examples I've seen online I think it should be working with what I have but the service is returning an error through the <code>webSocket:didFailWithError:</code> method.  Here's the error:</p>
  
  <pre><code>Error Domain=org.lolrus.SocketRocket Code=2132 "received bad response code from server 403" UserInfo={NSLocalizedDescription=received bad response code from server 403}
  </code></pre>
  
  <p>Here's my code for setting up the connection, found in our AppDelegate file:</p>
  
  <pre><code>&lt;!-- language:objective c --&gt;
  -(void)initializePushNotificationsConnection
  {
      // Connect to the hub on the service
      SRHubConnection* localHubConnection = [SRHubConnection connectionWithURL:kSignalRServiceUrl];
      SRHubProxy* notifications = (SRHubProxy*)[localHubConnection createHubProxy:@"notificationHub"];
      [notifications on:@"notificationSent" perform:self selector:@selector(addMessage:)];
  
      localHubConnection.started =  ^{
  
          NSString* userGuid = [OURAppSettings sharedSettings].loginModel.theUser.userGuid;
          if (!userGuid)
              userGuid = @"";
  
          NSString* connId = self.hubConnection.connectionId;
          if (!connId)
              connId = @"";
  
          NSDictionary* connectionDict = @{@"UserGuid": userGuid, @"Model": connId};
          NSData* jsonData = [NSJSONSerialization dataWithJSONObject:connectionDict options:0 error:nil];
          NSURL* connectionRegistrationServiceUrl = [NSURL URLWithString:kSignalRConnectionRegistrationUrl];
          NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:connectionRegistrationServiceUrl];
          [request setHTTPMethod:@"POST"];
          [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
          [request setHTTPBody:jsonData];
  
          [NSURLConnection sendAsynchronousRequest:request
                                             queue:[NSOperationQueue mainQueue]
                                 completionHandler:^(NSURLResponse* response, NSData* data, NSError* connectionError)
           {
               if (connectionError)
               {
                   NSLog(@"Error: %@", connectionError);
                   return;
               }
           }];
  
          return;
      };
  
      //Set the object to the local property to break the strong connection so the block can reference the object
      self.hubConnection = localHubConnection;
      SRWebSocketTransport *webSocket = [[SRWebSocketTransport alloc] init];
      [self.hubConnection start:webSocket];
  }
  </code></pre>
  
  <p>I've tried multiple suggestions from Github and SO but none of them are solving this issue.  I suspect there is a problem with how the web service is setup but I'm not an IIS expert nor do I have easy access to the setup. I'm basically just guessing at solutions at this point, so if anyone has any thoughts or suggestions at all I'm open to hearing them.</p>