连续第5次RestKit呼叫未被发送

时间:2012-03-27 17:05:16

标签: ios restkit

我正在通过RestKit发送一个objectManager postObject调用。在4次尝试返回403后,我的第5次尝试没有被拿起并由RestKit发出。我已经使用Charles验证了这一点以查看我的实际流量,并且通过查看RestKit日志,RestKit正在接收我的请求并将其放入RequestQueue中,但它永远不会被取消。

我的前4个请求在RestKit日志中看起来像这样(对于日志墙道歉):

D restkit:RKObjectManager.m:171 CacheTimeoutSet: 60.000000 - 60.000000
T restkit.network.queue:RKRequestQueue.m:226 Request <RKObjectLoader: 0x784ac90> added to queue <RKRequestQueue: 0x6501530>
T restkit.network.queue:RKRequestQueue.m:173 Processing request <RKObjectLoader: 0x784ac90> in queue <RKRequestQueue: 0x6501530>
T restkit.network.queue:RKRequestQueue.m:104 Loading count increasing from 0 to 1. Firing requestQueueDidBeginLoading
T restkit.network.queue:RKRequestQueue.m:131 Loading count set to 1 for queue <RKRequestQueue: 0x6501530>
T restkit.network.cache:RKRequestCache.m:106 Found cachePath '<REMOVED>' for <RKObjectLoader: 0x784ac90>
T restkit.network.cache:RKRequestCache.m:123 Determined hasResponseForRequest: <RKObjectLoader: 0x784ac90> => NO
D restkit.network:RKRequest.m:255 Sending asynchronous POST request to URL <REMOVED>.
D restkit.network:RKObjectLoader.m:295 POST or PUT request for source object <TSLAuthenticationContract: 0x7849b30>
    Username:<REMOVED>
    Campus:<REMOVED>, serializing to MIME Type application/json for transport...
D restkit.object_mapping:RKObjectMappingOperation.m:391 Starting mapping operation...
T restkit.object_mapping:RKObjectMappingOperation.m:231 Mapping attribute value keyPath 'username' to 'Username'
T restkit.object_mapping:RKObjectMappingOperation.m:241 Mapped attribute value from keyPath 'username' to 'Username'. Value: <REMOVED>
T restkit.object_mapping:RKObjectMappingOperation.m:231 Mapping attribute value keyPath 'password' to 'Password'
T restkit.object_mapping:RKObjectMappingOperation.m:241 Mapped attribute value from keyPath 'password' to 'Password'. Value: <REMOVED>
T restkit.object_mapping:RKObjectMappingOperation.m:231 Mapping attribute value keyPath 'campusName' to 'CampusName'
T restkit.object_mapping:RKObjectMappingOperation.m:241 Mapped attribute value from keyPath 'campusName' to 'CampusName'. Value: <REMOVED>
D restkit.object_mapping:RKObjectMappingOperation.m:397 Finished mapping operation successfully...
T restkit.network.cache:RKRequestCache.m:106 Found cachePath '<REMOVED>' for <RKObjectLoader: 0x784ac90>
D restkit.network.cache:RKRequestCache.m:220 Read nil cached headers from cachePath '<REMOVED>' for '<RKObjectLoader: 0x784ac90>'
D restkit.network.cache:RKRequestCache.m:245 Found cached ETag '(null)' for '<RKObjectLoader: 0x784ac90>'
T restkit.network:RKRequest.m:209 Prepared POST URLRequest '<NSMutableURLRequest <REMOVED>>'. HTTP Headers: <REMOVED>.
D restkit.network.queue:RKRequestQueue.m:180 Sent request <RKObjectLoader: 0x784ac90> from queue <RKRequestQueue: 0x6501530>. Loading count = 1 of 4
T restkit.network.queue:RKRequestQueue.m:142 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x6501530>
<REMOVED - Multiple Timer messages>
T restkit.network.queue:RKRequestQueue.m:142 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x6501530>
D restkit.network:RKResponse.m:105 NSHTTPURLResponse Status Code: 403

然而,在我的第5次电话会议中会发生这种情况:

D restkit:RKObjectManager.m:171 CacheTimeoutSet: 60.000000 - 60.000000
T restkit.network.queue:RKRequestQueue.m:226 Request <RKObjectLoader: 0x782a370> added to queue <RKRequestQueue: 0x6501530>
T restkit.network.queue:RKRequestQueue.m:142 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x6501530>
<REMOVED - Multiple Timer messages>
T restkit.network.queue:RKRequestQueue.m:142 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x6501530>

正如您所看到的,没有处理请求日志,没有加载计数日志,在将请求添加到队列后没有任何内容。有谁之前经历过这个吗?是否有一些内部计数器阻止RestKit再次进行此调用?我的用户不是非常技术性的,并且存在密码问题,所以他们连续4次验证失败并不是不可想象的。

修改 经过更多研究后,似乎RestKit在获取失败的响应时没有减少objectLoader中的loadingCount标志。不幸的是,我不确定如何解决这个问题。它是否像在我的代理中检查403并在我找到它时手动删除请求一样简单?

编辑2: 好的,我能够通过在我的objectLoader:didFailWithError:delegate方法中调用RKRequestQueue cancelRequest来强制删除失败的请求。不确定这是否是正确的方法,但它确实有效。我希望RestKit在内部处理这个问题。

谢谢, 罗布

2 个答案:

答案 0 :(得分:0)

也发生在我身上 我注意到我得到了不好的exec,所以我运行Xcode Profiling,我注意到我正在发布运行请求的对象到早期

正确保留后,它就解决了

答案 1 :(得分:0)

我把我的解决方案编辑到我的问题中,但是为了让这里的人感到高兴,这又是一个公认的答案。

  

经过更多研究后,似乎RestKit并未减少   在获取失败的响应时,objectLoader中的loadingCount标志。   不幸的是,我不确定如何解决这个问题。是吗?   很简单,检查我的代表中的403并删除请求   如果我发现它,请手动?

     

好的,我能够强制删除失败的请求   调用RKRequestQueue cancelRequest:在我的   objectLoader:didFailWithError:委托方法。不确定是不是   正确的方法,但它的工作原理。我希望RestKit内部   处理了这个问题。