Skip to end of metadata
Go to start of metadata

Since build 2.6.8 it is possible to add custom HTTP headers while establishing Websocket connection to WCS server. To do this, use the following function

FPWCSApi2Session connectWithHeaders:(NSDictionary<NSString *, NSString *> *) headers

Suppose that Websocket traffic proxying with user authentication is configured on the server using nginx. In this case, user credentials should be passed in Websocket URL


In this case, Authorization HTTP header should be formed from Websocket URL and should be sent while connecting to the server as follows:


        NSURL* nsURL = [NSURL URLWithString:_urlInput.text];
        if (nsURL.user && nsURL.password) {
            NSString* auth = [NSString stringWithFormat:@"%@:%@", nsURL.user, nsURL.password];
            NSData *authData = [auth dataUsingEncoding:NSUTF8StringEncoding];
            NSString *authBase64 = [NSString stringWithFormat:@"Basic %@", [authData base64EncodedStringWithOptions:kNilOptions]];
            NSDictionary *headers = [[NSDictionary alloc] initWithObjectsAndKeys: authBase64, @"Authorization", nil];
            [_session connectWithHeaders: headers];
        } else {
            [_session connect];
  • No labels