DyKnow / SignalR-ObjC

Objective-C Client for the SignalR Project works with iOS and Mac
MIT License
442 stars 213 forks source link

Server Sent Events does not fallback to LongPolling #95

Closed abillingsley closed 12 years ago

abillingsley commented 12 years ago

The way in which we are using NSOutputStream for SSE is preventing the transport from falling back when it should.

An easy way to force transport failure is to change the value for kTransportName on the transport. This will call it to be "faulted" at which point the transport should fallback assuming there is a transport to fallback to.

Changing kTransportName to "serversentevents1" in the serverSentEvents Transport properly raises the faulted case but the transport is incorrectly initialized already so it does not notify the AutoTransport that it should fallback to LongPolling

abillingsley commented 12 years ago

Did some initial digging around this one. It appears that opened is called prematurely in SSE. In the specific example above. SignalR returens a Server Error which is immediately written to the NSOutputStream, to the EventStreamReader this appears as if the stream was properly opened which causes the EventStreamReader to call open and the callbackInvoker to be invoked. Shortly after processing the data we get the callback from AFNetworking that the connection failed which is properly tries to call the callbackInvoker but it has already been invoked once and is therefore not invoked a second time.