• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Prevent NSURLConnection retry
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Prevent NSURLConnection retry


  • Subject: Re: Prevent NSURLConnection retry
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 29 Nov 2011 13:02:48 -0800


On Nov 29, 2011, at 10:31 AM, Jeff Johnson wrote:

I'm using NSURLConnection to update song information on a SHOUTcast server. This is done via an HTTP GET request with the path format "/admin?song=“.

Wow, really? That’s a terrible design on their part; GETs are supposed to be read-only and idempotent (precisely because of problems like the one you’re running into.) But from what I recall, Shoutcast/Icecast is an incredibly kludgy protocol :-p

Unfortunately, SHOUTcast is very poorly designed, so it does not give an HTTP response to the request. Instead, it simply does ACK and then FIN. This seems to cause NSURLConnection to retry twice (on different source ports) before giving up. The result is that the song information is updated three times on the SHOUTcast server instead of once, because there are three GET requests.
Is there any way to prevent NSURLConnection from retrying after the connection is closed?

I don’t think so. What it’s doing is appropriate for any reasonable server, so I doubt anyone would have added an option to turn it off.

Your best bet is probably to send the request yourself using a raw NSStream. Pretty much all you have to do is open a stream to the host and send “GET /admin?song=%@ HTTP/1.1\r\nHost: %@\r\n\r\n”, where the first param is the track name and the second is the DNS name of the server.

This still won’t solve the problem if there are any HTTP proxies between you and the server, because they’re likely to use the same retry behavior when they relay your request.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Prevent NSURLConnection retry
      • From: Jeff Johnson <email@hidden>
References: 
 >Prevent NSURLConnection retry (From: Jeff Johnson <email@hidden>)

  • Prev by Date: Prevent NSURLConnection retry
  • Next by Date: Re: Prevent NSURLConnection retry
  • Previous by thread: Prevent NSURLConnection retry
  • Next by thread: Re: Prevent NSURLConnection retry
  • Index(es):
    • Date
    • Thread