stringWithContentsOfURL returns nil

  • Hi,
    one of my client, only one, gets a null string from the API
    stringWithContentsOfURL. His firewall is off.

    NSError    *error = nil;
    NSString    *aStr = [NSString stringWithContentsOfURL:aURL
                        encoding:NSASCIIStringEncoding error:&error];

    The error description is
    "File could not be opened." Domain=NSCocoaErrorDomain Code=256
    UserInfo={}

    How can I detect and fix the trouble?
    Should I look into his modem settings? He uses airport extreme.
    I have no idea about the solution. Thanks.

    Best Regards
    --
    Lorenzo
    email: <archidea...>
  • > How can I detect and fix the trouble?
    > Should I look into his modem settings? He uses airport extreme.
    > I have no idea about the solution. Thanks.

      Can the user load the URL with a browser? If not, perhaps there is a
    firewall or proxy issue. If they can load the URL just fine with a web
    browser (ie, they don't get an error in Safari of any kind), I'd file
    a bug report with Apple due to the rather unhelpful "error". The
    number 256 seems like a catch-all of some kind to me.

    --
    I.S.
  • Hi, thank you for your prompt reply.
    The url is a php file always present on my web site.
    Me and all of my clients can always reach this file.
    Only one client gets a null string. And his firewall on MacOSX 10.4.11 is
    off. Together with the link I pass some data like the version number, e.g.
        http://www.mydomain.com/check.php?sn=123456
    Could the computer block just this kind of calls, because they send data?
    If so, what should I look to fix the trouble? As I have said the client's
    firewall is off. But, could an extra unknown firewall or control work on his
    modem?

    Yes, the client generally can see my web pages with Safari.
    But I can't give him just the link of the php file.
    The php file has the following privileges: rw-r--r--
    Its parent folder's permissions are:      rwx--x--x
    Are those permissions correct? If not, why do the other clients can properly
    read the php page?

    Last, I have tried to call a non existing domain, e.g.
        http://xxx.oadosa.poiopisadp
    and I got a null string with a different error message:
        Error Domain=NSCocoaErrorDomain Code=260 UserInfo=0x14a908f0 "The file
        ³check.php² does not exist."
    Instead if I just call a non existing file on my web site I get a 404 error
    page so the string returned by stringWithContentsOfURL is not null.
    Then I suppose the trouble comes from the permissions? How to fix this?

    Best Regards
    --
    Lorenzo
    email: <archidea...>

    > From: Hamish Allan <hamish...>
    > Date: Tue, 05 Feb 2008 19:11:52 +0000
    > To: <archidea...>
    > Subject: Re: stringWithContentsOfURL returns nil
    >
    > On Feb 5, 2008 7:06 PM,  <archidea...> wrote:
    >
    >> The error description is
    >> "File could not be opened." Domain=NSCocoaErrorDomain Code=256
    >> UserInfo={}
    >
    > That is just the sort of error message I would expect if the URL could
    > not be reached. So without knowing what the URL is, whether it can be
    > reached by other means, etc., it's pretty much impossible to diagnose.
    >
    > Hamish
  • > The url is a php file always present on my web site.
    > Me and all of my clients can always reach this file.

      Okay, so the problem is local to the user.

    > Only one client gets a null string. And his firewall on MacOSX 10.4.11 is
    > off. Together with the link I pass some data like the version number, e.g.
    > http://www.mydomain.com/check.php?sn=123456

      Looks reasonable.

    > Could the computer block just this kind of calls, because they send data?
    > If so, what should I look to fix the trouble? As I have said the client's
    > firewall is off. But, could an extra unknown firewall or control work on his
    > modem?

      Sure. There are all kinds of content blockers that can be following
    any number of rules. That's why you need to *test it*.

    > Yes, the client generally can see my web pages with Safari.
    > But I can't give him just the link of the php file.

      Why not? His app is calling it. Have the user send what the app
    sends. If you're just trying to protect this URL as a "secret", I'd
    advise you to give up that pursuit. The security-through-obscurity
    approach to hiding a URL is ridiculous given Google and the many tools
    an astute power user has at his/her disposal for figuring out what
    pages are being loaded by their computers' apps.

      If you really don't want to do this, we really can't help you.

    > The php file has the following privileges: rw-r--r--
    > Its parent folder's permissions are:      rwx--x--x
    > Are those permissions correct? If not, why do the other clients can properly
    > read the php page?

      Irrelevant since you and others can get to this page. Also off-topic
    for cocoa-dev, so we'll leave this one alone and assume it's fine.

    > Last, I have tried to call a non existing domain, e.g.
    > http://xxx.oadosa.poiopisadp
    > and I got a null string with a different error message:
    > Error Domain=NSCocoaErrorDomain Code=260 UserInfo=0x14a908f0 "The file
    > ³check.php² does not exist."
    > Instead if I just call a non existing file on my web site I get a 404 error
    > page so the string returned by stringWithContentsOfURL is not null.
    > Then I suppose the trouble comes from the permissions? How to fix this?

      What leads you to that conclusion? If others can reach it, the
    problem is local to the user's network or computer. GIVE THE USER THE
    URL AND HAVE HIM/HER TEST IT. There is *nothing* more you can do
    without that vital step and if your security relies on nobody knowing
    or finding that URL, your security is flawed anyway, so you're not
    losing anything by disclosing it to the user.

    --
    I.S.
  • On Feb 5, 2008, at 23:19, <archidea...> <archidea...> wrote:

    > http://www.mydomain.com/check.php?sn=123456
    > Could the computer block just this kind of calls, because they send
    > data?
    > If so, what should I look to fix the trouble? As I have said the
    > client's
    > firewall is off. But, could an extra unknown firewall or control
    > work on his
    > modem?

    It can - depending on how broken the "firewall" :-)

    You can use nicer and safer url like:

    http://www.mydomain.com/update/123456

    On the server side, you configure the server to handle any url that
    starts with /update with the script update.php. If the url has one
    path component, treat it like the serial number. If not, return 404.

    This way you can also change your implementation later (e.g. replace
    with a Python or Ruby script) without changing the interface for the
    clients.

    Best Regards,

    Nir Soffer
  • Yes, my client can properly reach that link on my web site using Safari.
        http://www.mydomain.com/check.php?sn=123456
    He got the response-text on the browser.

    Any idea?

    Best Regards
    --
    Lorenzo
    email: <archidea...>

    > From: "I. Savant" <idiotsavant2005...>
    > Date: Tue, 05 Feb 2008 16:29:32 -0500
    > To: <archidea...>
    > Cc: <cocoa-dev...>
    > Subject: Re: stringWithContentsOfURL returns nil
    >
    >> The url is a php file always present on my web site.
    >> Me and all of my clients can always reach this file.
    >
    > Okay, so the problem is local to the user.
    >
    >> Only one client gets a null string. And his firewall on MacOSX 10.4.11 is
    >> off. Together with the link I pass some data like the version number, e.g.
    >> http://www.mydomain.com/check.php?sn=123456
    >
    > Looks reasonable.
    >
    >> Could the computer block just this kind of calls, because they send data?
    >> If so, what should I look to fix the trouble? As I have said the client's
    >> firewall is off. But, could an extra unknown firewall or control work on his
    >> modem?
    >
    > Sure. There are all kinds of content blockers that can be following
    > any number of rules. That's why you need to *test it*.
    >
    >> Yes, the client generally can see my web pages with Safari.
    >> But I can't give him just the link of the php file.
    >
    > Why not? His app is calling it. Have the user send what the app
    > sends. If you're just trying to protect this URL as a "secret", I'd
    > advise you to give up that pursuit. The security-through-obscurity
    > approach to hiding a URL is ridiculous given Google and the many tools
    > an astute power user has at his/her disposal for figuring out what
    > pages are being loaded by their computers' apps.
    >
    > If you really don't want to do this, we really can't help you.
    >
    >> The php file has the following privileges: rw-r--r--
    >> Its parent folder's permissions are:      rwx--x--x
    >> Are those permissions correct? If not, why do the other clients can properly
    >> read the php page?
    >
    > Irrelevant since you and others can get to this page. Also off-topic
    > for cocoa-dev, so we'll leave this one alone and assume it's fine.
    >
    >> Last, I have tried to call a non existing domain, e.g.
    >> http://xxx.oadosa.poiopisadp
    >> and I got a null string with a different error message:
    >> Error Domain=NSCocoaErrorDomain Code=260 UserInfo=0x14a908f0 "The file
    >> ³check.php² does not exist."
    >> Instead if I just call a non existing file on my web site I get a 404 error
    >> page so the string returned by stringWithContentsOfURL is not null.
    >> Then I suppose the trouble comes from the permissions? How to fix this?
    >
    > What leads you to that conclusion? If others can reach it, the
    > problem is local to the user's network or computer. GIVE THE USER THE
    > URL AND HAVE HIM/HER TEST IT. There is *nothing* more you can do
    > without that vital step and if your security relies on nobody knowing
    > or finding that URL, your security is flawed anyway, so you're not
    > losing anything by disclosing it to the user.
    >
    > --
    > I.S.
  • On Feb 5, 2008, at 6:49 PM, <archidea...> <archidea...> wrote:

    > Yes, my client can properly reach that link on my web site using
    > Safari.
    > http://www.mydomain.com/check.php?sn=123456
    > He got the response-text on the browser.
    >
    > Any idea?

      Okay, so that eliminates anything computer-wide and network-wide
    that would be standing in the way. The last thing to check is if
    there's something specific to the app. Is the user running anything
    like Little Snitch, which blocks communication at the application-level?

      If not, what happens if the user creates a new account on the
    machine and tries this process from that account?

    --
    I.S.
previous month february 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29    
Go to today
MindNode
MindNode offered a free license !