zwopple / PocketSocket

Objective-C websocket library for building things that work in realtime on iOS and OS X.
Other
414 stars 129 forks source link

Support for HTTP proxy configuration #20

Open artmatsak opened 9 years ago

artmatsak commented 9 years ago

First of all, thank you for a great library. It works great in our iOS app!

Now, we have been contacted by a user who is unable to connect on their iPad. They use an HTTP proxy (settings entered globally under the system Settings/Wi-Fi).

Does PocketSocket respect/use the global iOS HTTP proxy settings? If not, is it possible to make PocketSocket use a proxy in some other way?

snej commented 9 years ago

You can call CFNetworkCopySystemProxySettings() to get the proxy settings, and store the resulting CBDictionary as the value of the stream property kCFStreamPropertyHTTPProxy. But it would be better if PSWebSocket did this itself.

cerupcat commented 9 years ago

I'm having the same issue. Where in the code did you enable this? I've tried adding it to the outputStream but it's not working.

snej commented 9 years ago

I haven't gotten around to adding this to PSWebSocket yet. But I've got another stream in my app that I configure proxies for like so:

    CFDictionaryRef proxySettings = CFNetworkCopySystemProxySettings();
    if (proxySettings) {
        __unused Boolean ok = CFReadStreamSetProperty(cfInputStream, kCFStreamPropertyHTTPProxy, proxySettings);
        Assert(ok);
        CFRelease(proxySettings);
    }

It's not supposed to make a difference whether you add the setting to the input or output stream, but since I used the inputStream before, why not try that one.

snej commented 9 years ago

PS: If you haven't seen it yet, my fork of PocketSocket has a lot of extra features and bug-fixes. It's not in use in a product yet but it will be soon (Couchbase Lite 1.2.)

robertjpayne commented 8 years ago

Unfortunately proxies are sort of painful to implement at the CFNetworking level. On iOS particularly I've never had luck getting them to work even using the appropriate property keys.